使用如下SQL语句查询出表中外键约束名称:
select name
from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
where f.parent_object_id=object_id(‘表名’)
只需将表名改成所要查询的表名即可得到外键名
执行如下SQL语句删除即可。
1 alter table 表名 drop constraint 外键约束名
使用如下SQL语句查询出表中外键约束名称:
select name
from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
where f.parent_object_id=object_id(‘表名’)
只需将表名改成所要查询的表名即可得到外键名
执行如下SQL语句删除即可。
1 alter table 表名 drop constraint 外键约束名