删除constraint为变量名的约束

 1 create procedure DropPK_MESSAGEUSERS
 2 as
 3 begin
 4 declare @pk_name varchar(100) 
 5 SELECT @pk_name=CONSTRAINT_NAME 
 6 from INFORMATION_SCHEMA.TABLE_CONSTRAINTS 
 7 WHERE CONSTRAINT_NAME like '%messageusers%' and 
 8 CONSTRAINT_TYPE='primary KEY'  
 9 exec('alter table [MESSAGEUSERS] drop constraint '+ @pk_name)
10 end 

question:

相同的建库脚本,若脚本中含有创建主键的定义。

生成的主键名在不同的环境下是否是相同的?

原文地址:https://www.cnblogs.com/thxuaimin/p/3570894.html