SQL delete foreign key constraint

  

Use the following SQL statement to query a table and foreign key constraint name:

1 select name  
2 from  sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id 
3 where f.parent_object_id=object_id('表名')

Execute the following SQL statement can be deleted.

1 alter table 表名 drop constraint 外键约束名

 

 

 

Reproduced in: https: //my.oschina.net/weisenz/blog/200655

Guess you like

Origin blog.csdn.net/weixin_34237596/article/details/91920860