这个未记录的RAISERROR语法是否已被记录,随后被弃用? [英] Was this undocumented RAISERROR syntax ever documented and subsequently deprecated?
问题描述
我正在开发一个大型的SQL Server代码库,其中一些从至少SQL 7开始就可以开发。
在整个代码库中,提出错误的方法是使用以下语法,就我所知,无证件
RAISERROR<错误数> < error message>
错误号
可以是任何更大的值超过13000; sys.messages
表中不存在相应的条目。 错误消息
也可以是任意的。
以下示例代码
raiserror 13000'test error'
以下输出
消息13000,级别16,状态1,行1
测试错误
这个行为在SQL 2000,2005和2008中是一样的(我还没有测试2008 R2)。
我们将尝试对支持的方法进行标准化,但是我的问题是这个行为来自哪里。首先,
我认为这必须曾被记录在案,支持的行为,但是在线阅读SQL 7和以前版本的书籍很难找到。有没有人知道这是支持还是被弃用的,如果有的话?
修改
要澄清,根据<一个href =http://msdn.microsoft.com/en-us/library/ms178592.aspx =noreferrer>文档,支持的 RAISERROR
语法是
RAISERROR({msg_id | msg_str | @local_variable}
{,severity,state}
[,参数[,... n]])
[WITH选项[,... n]]
任何未在 sys.messages
中定义的任何用户错误编号都应引发错误消息标识为50000
这看起来像是可能是SQL Server的起源在Sybase中的一个回退,其中 RAISERROR
命令有这个确切的语法:
无论其起源,SQL Server 2008 R2都不推荐使用此语法,并将在SQL Server 2012(v 11. x )中删除。请参阅 SQL Server 2008 R2中已弃用的数据库引擎功能页面了解详情。
I'm working on a large SQL Server codebase, some of which has been in development since at least SQL 7 and possibly before.
Throughout the codebase, the method of raising an error is to use the following syntax which is, as far as I can tell, undocumented
RAISERROR <error number> <error message>
The error number
can be any value greater than 13000; no corresponding entry needs to exist in the sys.messages
table. The error message
can also be arbitrary.
The following sample code
raiserror 13000 'test error'
produces the following output
Msg 13000, Level 16, State 1, Line 1
test error
This behaviour is the same in SQL 2000, 2005 and 2008 (I haven't tested 2008 R2).
We're going to attempt to standardise on a supported method, but my question is where this behaviour came from in the first place.
I assume this must once have been documented, supported behaviour, but copies of books online for SQL 7 and before are difficult to find. Does anybody know when this was supported or when it was deprecated, if ever?
Edit
To clarify, according to the documentation, the supported RAISERROR
syntax is
RAISERROR ( { msg_id | msg_str | @local_variable }
{ ,severity ,state }
[ ,argument [ ,...n ] ] )
[ WITH option [ ,...n ] ]
And any user error number which is not defined in sys.messages
should be raised with an error message id of 50000
This looks like it might be a throwback to SQL Server's origins in Sybase, whose RAISERROR
command has this exact syntax:
Whatever its origins, this syntax is deprecated as of SQL Server 2008 R2 and will be removed in SQL Server 2012 (v 11.x). See the Deprecated Database Engine Features in SQL Server 2008 R2 page for details.
这篇关于这个未记录的RAISERROR语法是否已被记录,随后被弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!