Mega Code Archive

 
Categories / MSSQL Tutorial / Transact SQL
 

Using RAISERROR with the SETERROR Option

6> sp_addmessage 7>   60000, 8>   16, 9>   'Unable to find ID %09d' 10> GO Msg 15043, Level 16, State 1, Server BCE67B1242DE45A\SQLEXPRESS, Procedure sp_addmessage, Line 137 You must specify 'REPLACE' to overwrite an existing message. 1> 2> 3> RAISERROR (60000, 1, 2) 4> SELECT @@ERROR 5> GO Unable to find ID (null) -----------           0 (1 rows affected) 1> RAISERROR (60000, 1, 2) WITH SETERROR 2> SELECT @@ERROR 3> 4> sp_dropmessage 5>   60000 6> GO Msg 102, Level 15, State 1, Server BCE67B1242DE45A\SQLEXPRESS, Line 5 Incorrect syntax near '60000'. 1>