在MS SQL中调用存储过程后“; 1”? [重复]

时间:2022-07-02 16:39:33

This question already has an answer here:

这个问题在这里已有答案:

Doing some maintenance on an old report created by someone long ago. I notice data source for the report is a stored procedure. The sproc call looks like this:

对很久以前由某人创建的旧报告进行一些维护。我注意到报告的数据源是一个存储过程。 sproc调用看起来像这样:

EXEC someStoredProc;1

I've never seen the ";1" before. Just curious what the heck it is? Can't find any documentation online. If I switch the "1" to any other number, SQL throws error "cannot find stored procedure 'someStoredProc'". But switch it back to "1" and it works. Doesn't seem to have any impact on output. What is this thing?

我以前从未见过“1”。只是好奇它到底是什么?在网上找不到任何文档。如果我将“1”切换为任何其他数字,则SQL抛出错误“无法找到存储过程'someStoredProc'”。但是将它切换回“1”并且它可以工作。似乎对输出没有任何影响。这是什么?

I noticed I can put ";1" after any stored procedure and it executes seemingly the same as without it.

我注意到我可以在任何存储过程之后加上“; 1”,并且它执行看似与没有它一样。

If anyone can clear up this mystery for me - thank you!

如果有人能为我清理这个谜 - 谢谢!

1 个解决方案

#1


5  

These are known as Numbered Procedures, which have been deprecated since 2005 (but are still somewhat supported through SQL Server 2012)

这些被称为编号过程,自2005年以来已被弃用(但仍通过SQL Server 2012得到支持)

In SQL Server, you can create different versions of the stored procedure with a ;# suffix. These can generally be used to overload a stored procedure, by creating another version that accepts a different number of parameters, or behaves differently, etc.

在SQL Server中,您可以使用;#suffix创建存储过程的不同版本。这些通常可用于重载存储过程,通过创建另一个接受不同数量参数的版本,或行为不同等。

#1


5  

These are known as Numbered Procedures, which have been deprecated since 2005 (but are still somewhat supported through SQL Server 2012)

这些被称为编号过程,自2005年以来已被弃用(但仍通过SQL Server 2012得到支持)

In SQL Server, you can create different versions of the stored procedure with a ;# suffix. These can generally be used to overload a stored procedure, by creating another version that accepts a different number of parameters, or behaves differently, etc.

在SQL Server中,您可以使用;#suffix创建存储过程的不同版本。这些通常可用于重载存储过程,通过创建另一个接受不同数量参数的版本,或行为不同等。