将用户消息绑定到参照完整性约束或检查约束。
sp_bindmsg <constrname>, <msgid>
<constrname>
是向其绑定消息的完整性约束的名称。使用 create table 命令的 constraint 子句或 alter table 命令的 add constraint 子句创建和命名约束。
<msgid>
是要绑定到完整性约束的用户消息的编号。在调用 sp_bindmsg 之前,该消息必须存在于本地数据库的 sysusermessages 表中。
将编号为 20100 的用户消息绑定到 positive_balance 约束。
sp_bindmsg positive_balance, 20100
使用 sp_bindmsg 时,还存在一些其它注意事项:
sp_bindmsg 通过将消息号添加到 sysconstraints 表中的约束行将用户消息绑定到完整性约束。
sysconstraints 表中的旧消息号。
sysconstraints 中没有约束行(唯一约束是唯一索引)。
sp_addmessage 过程将用户消息插入 sysusermessages 表中。
sp_getmessage 过程从 sysusermessages 表中检索消息文本。
sp_help <tablename> 显示在 <tablename> 上声明的所有约束名。