SQL Server/T-SQL Tutorial/System Functions/sp addmessage

Материал из SQL эксперт
Перейти к: навигация, поиск

Adding a custom error

5> EXEC sp_addmessage
6>     @msgnum = 50005,
7>     @severity = 16,
8>     @msgtext = "Problem with ProductIds %i, %i, %i"
9> GO
Msg 15043, Level 16, State 1, Server J\SQLEXPRESS, Procedure sp_addmessage, Line 137
You must specify "REPLACE" to overwrite an existing message.
1>
2>


Adding a message to the sysmessages table using the REPLACE option.

3>
4>
5> sp_addmessage 50001, 12, "The specified value for %s was invalid."
6>               , US_English, TRUE, REPLACE
7> GO


Adding Entries to sysmessages

4>
5> sp_addmessage 50001, 12, "A number greater than 0 was expected. Please retry"
6> GO