Retrieves stored message strings from sysmessages and sysusermessages for print and raiserror statements.
sp_getmessage message_num, result output [, language]
is the number of the message to be retrieved.
is the variable that receives the returned message text, followed by a space and the keyword output. The variable must have a datatype of char, unichar, nchar, varchar, univarchar, or nvarchar.
is the language of the message to be retrieved. language must be a valid language name in syslanguages table. If you include language, the message with the indicated message_num and language is retrieved. If you do not include language, then the message for the default session language, as indicated by the variable @@langid, is retrieved.
Retrieves message number 20001 from sysusermessages:
declare @myvar varchar(200) exec sp_getmessage 20001, @myvar output
Retrieves the French language version of message number 20010 from sysusermessages:
declare @myvar varchar(200) exec sp_getmessage 20010, @myvar output, french
Any application can use sp_getmessage, and any user can read the messages stored in sysmessages and sysusermessages.
Any user can execute sp_getmessage.
Values in event and extrainfo columns from the sysaudits table are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
38 |
exec_procedure |
Execution of a procedure |
|
System procedures sp_addmessage, sp_dropmessage