sp_bindmsg

Binds a user message to a referential integrity constraint or check constraint.

Syntax

sp_bindmsg constrname, msgid

Parameters

Examples

Usage

There are additional considerations when using sp_bindmsg:
  • sp_bindmsg binds a user message to an integrity constraint by adding the message number to the constraint row in the sysconstraints table.

  • Only one message can be bound to a constraint. To change the message for a constraint, just bind a new message. The new message number replaces the old message number in the sysconstraints table.

  • You cannot bind a message to a unique constraint because a unique constraint does not have a constraint row in sysconstraints (a unique constraint is a unique index).

  • Use the sp_addmessage procedure to insert user messages into the sysusermessages table.

  • The sp_getmessage procedure retrieves message text from the sysusermessages table.

  • sp_help tablename displays all constraint names declared on tablename.

See also alter table, create table in Reference Manual: Commands.

Permissions

You must be the constraint owner to execute sp_bindmsg. Permission checks do not differ based on the granular permissions settings.

Auditing

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

InformationValues
Event

7

Audit option

bind

Command or access audited

sp_bindmsg

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – Message ID

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

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

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

Related reference
sp_addmessage
sp_getmessage
sp_unbindmsg