sp_addmessage

Adds user-defined messages to sysusermessages for use by stored procedure print and raiserror calls and by sp_bindmsg.

Syntax

sp_addmessage message_num, message_text 
	[, language [, with_log [, replace]]]

Parameters

Examples

Usage

sp_addmessage does not overwrite an existing message of the same number and langid unless you specify @replace = “replace".

print and raiserror recognize placeholders in the message text to print out. A single message can contain up to 20 unique placeholders in any order. These placeholders are replaced with the formatted contents of any arguments that follow the message when the text of the message is sent to the client.

The placeholders are numbered to allow reordering of the arguments when the SAP ASE server is translating a message to a language with a different grammatical structure. A placeholder for an argument appears as “%nn!”, a percent sign (%), followed by an integer from 1 to 20, followed by an exclamation point (!). The integer represents the argument number in the string in the argument list. “%1!” is the first argument in the original version, “%2!” is the second argument, and so on.

Only the user who created a message can execute sp_addmessage with the replace option to replace that original message.

See also print, raiserror in Reference Manual: Commands.

Permissions

The permission checks for sp_addmessage differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, any user can execute sp_addmessage.

To add a message with with_log, you must be the database owner or a user with own database privilege on the database.

Disabled

With granular permissions disabled, any user can execute sp_addmessage.

To add a message with with_log, you must be the database owner or a user with sa_role.

Only the user who created the message can execute sp_addmessage with the replace option to replace that original message.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

15

Audit option

create

Command or access audited

sp_addmessage

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – Message number

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_altermessage
sp_bindmsg
sp_dropmessage
sp_getmessage