篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MS SQL RAISERROR相关的知识,希望对你有一定的参考价值。
-- Severity levels from 20 through 25 are
-- considered fatal. If a fatal severity level
-- is encountered, the client connection is terminated
-- after receiving the message, and the error is
-- logged in the error and application logs.
RAISERROR('Print', 10,1);
RAISERROR('Info', 14,1);
RAISERROR('Warning', 15,1);
RAISERROR('Critical', 16,1);
RAISERROR (15600,-1,-1, 'mysp_CreateCustomer');
-- Msg 15600, Level 15, State 1, Line 9
-- An invalid parameter or option was specified
-- for procedure 'mysp_CreateCustomer'.
RAISERROR('Raise a custom error', 12, 1) ;
-- Msg 50000, Level 12, State 1, Line 15
-- Raise a custom error
RAISERROR (N'This is message %s %d.', -- Message text.
10, -- Severity,
1, -- State,
N'number', -- First argument.
5);
-- This is message number 5.
RAISERROR (N'<\<%*.*s>>', -- Message text.
10, -- Severity,
1, -- State,
15, -- First argument used for width.
3, -- Second argument used for precision.
N'abcdefghi');
-- With Log
-- Logs can be viewed at :
-- SQL Server > Object Explorer >
-- Management > SQL Server Logs > Current
RAISERROR('Print', 10,1) WITH LOG;