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

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

Adding a custom error

   <source lang="sql">

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></source>


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

   <source lang="sql">

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


Adding Entries to sysmessages

   <source lang="sql">

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