SQL Server中RAISERROR的用法(二)

2014-11-24 15:32:42 · 作者: · 浏览: 1
过程,以消息号50005添加到 sys.messages 目录视图中。
sp_addmessage @msgnum = 50005,
@severity = 10,
@msgtext = N'<<%7.3s>>';
GO
RAISERROR (50005, -- Message id.
10, -- Severity,
1, -- State,
N'abcde'); -- First argument supplies the string.
-- The message text returned is: << abc>>.
GO
sp_dropmessage @msgnum = 50005;
GO
www.2cto.com
--示例7
--C. 使用局部变量提供消息文本
以下代码示例显示如何使用局部变量为 RAISERROR 语句提供消息文本。
sp_addmessage @msgnum = 50005,
@severity = 10,
@msgtext = N'<<%7.3s>>';
GO
RAISERROR (50005, -- Message id.
10, -- Severity,
1, -- State,
N'abcde'); -- First argument supplies the string.
-- The message text returned is: << abc>>.
GO
sp_dropmessage @msgnum = 50005;
GO