gpt4 book ai didi

sql-server - SQL Server : Why would i add ";1" to the end of a stored procedure name?

转载 作者:行者123 更新时间:2023-12-03 14:38:29 25 4
gpt4 key购买 nike

今天,作为一名客户从 Windows XP 升级到 Windows 7,我遇到了兼容性问题。

(12 年前的代码)正在调用 SQL Server 上名为

的存储过程
ai_nextid

除了当它调用存储过程时它使用的名称:

ai_nextid;1

是的,附加“;1”。显然,Windows 95、Windows 2000、Windows XP 和可能的 Windows Vista 中的 SQL Server 驱动程序可以使用这个特别添加的后缀。但Windows 7中的SQL Server ODBC驱动程序不同,并导致错误:

General SQL Error.
[Microsoft][ODBC SQL Driver][SQL Server]Could not find stored procedure 'ai_nextid;1'.
[Microsoft][ODBC SQL Driver][SQL Server]Indicator variable requried but not supplied'.

出现 native 错误 2812 .

这提出了 4 个问题:

  • 为什么我们要将 ;1 附加到存储过程名称的末尾? (它实现了什么)
  • 为什么 SQL Server 驱动程序忽略它?
  • 为什么要在 Windows 7 中进行重大更改?
  • 是否记录了重大兼容性更改?

最后两个问题可能是相同的,因为如果他们记录下来,他们就会证明它是合理的。

最佳答案

参见CREATE PROCEDURE (Transact-SQL) SQL Server 2008 documentation

--Transact-SQL Stored Procedure Syntax
CREATE { PROC | PROCEDURE } [schema_name.] procedure_name [ ; number ] <<<<<<
[ { @parameter [ type_schema_name. ] data_type }
[ VARYING ] [ = default ] [ OUT | OUTPUT ] [READONLY]
] [ ,...n ]
[ WITH <procedure_option> [ ,...n ] ]
[ FOR REPLICATION ]
AS { [ BEGIN ] sql_statement [;] [ ...n ] [ END ] }
[;]

<procedure_option> ::=
[ ENCRYPTION ]
[ RECOMPILE ]
[ EXECUTE AS Clause ]

;number

An optional integer that is used to group procedures of the same name. These grouped procedures can be dropped together by using one DROP PROCEDURE statement.

Note:

This feature will be removed in a future version of Microsoft SQL Server.
Avoid using this feature in new development work, and plan to
modify applications that currently use this feature.

Numbered procedures cannot use the xml or CLR user-defined types and cannot be used in a plan guide.

您可以使用此系统 View 来查找所有这些内容并开始将它们重写为单独的过程:

sys.numbered_procedures (Transact-SQL)

关于sql-server - SQL Server : Why would i add ";1" to the end of a stored procedure name?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3671270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com