sqlserver中的error是什么

如题所述

RAISERROR
返回用户定义的错误信息并设系统标志,记录发生错误。通过使用 RAISERROR 语句,客户端可以从 sysmessages 表中检索条目,或者使用用户指定的严重度和状态信息动态地生成一条消息。这条消息在定义后就作为服务器错误信息返回给客户端。

语法
RAISERROR ( { msg_id | msg_str } { , severity , state }
[ , argument [ ,...n ] ] )
[ WITH option [ ,...n ] ]

参数
msg_id

存储于 sysmessages 表中的用户定义的错误信息。用户定义错误信息的错误号应大于 50,000。由特殊消息产生的错误是第 50,000 号。

msg_str

是一条特殊消息,其格式与 C 语言中使用的 PRINTF 格式样式相似。此错误信息最多可包含 400 个字符。如果该信息包含的字符超过 400 个,则只能显示前 397 个并将添加一个省略号以表示该信息已被截断。所有特定消息的标准消息 ID 是 14,000。

msg_str 支持下面的格式:

% [[flag] [width] [precision] [{h | l}]] type

可在 msg_str 中使用的参数包括:

flag

用于确定用户定义的错误信息的间距和对齐的代码。

可以查阅一下SQL SERVER的联机丛书(在安装了MSSQL的开始菜单里可以查到)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2022-07-04
这种错误类型很多
1.The transaction should fail and an SQL error should occur.
提示事务失败,并且出现一个SQL错误。

2.Otherwise, the command fails with a Transact-SQL error.
否则,命令将由于Transact-SQL错误而失败。

3.With the property set this way, any SQL statements from the application that are not bound to the database will result in an SQL error.
这种方式设置该属性,应用程序中任何未绑定到数据库的SQL语句都将产生SQL错误。

4.For a Transact-SQL step, the most recent Transact-SQL error number encountered while running the command.
对于Transact-SQL步骤,指运行命令时遇到的最近的Transact-SQL错误号。

5.Attempting a DML operation on a table that is in alter mode results in SQL error code -19992.
如果尝试对alter模式下的表执行DML操作,则会产生SQL错误码-19992。
相似回答