Binds a user message to a referential integrity constraint or check constraint.
sp_bindmsg constrname, msgid
is the name of the integrity constraint to which you are binding a message. Use the constraint clause of the create table command, or the add constraint clause of the alter table command to create and name constraints.
is the number of the user message to be bound to an integrity constraint. The message must exist in the sysusermessages table in the local database prior to calling sp_bindmsg.
sp_bindmsg positive_balance, 20100
Binds user message number 20100 to the positive_balance constraint.
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.
Only the object owner can execute sp_bindmsg.
Values in event and extrainfo columns from the sysaudits table are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
7 |
bind |
sp_bindmsg |
|
38 |
exec_procedure |
Execution of a procedure |
|
Commands alter table, create table
System procedures sp_addmessage, sp_getmessage, sp_unbindmsg