码迷,mamicode.com
首页 > 其他好文 > 详细

Could not drop object 'student' because it is referenced by a FOREIGN KEY constraint

时间:2014-10-08 14:01:05      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:foreign key   drop table   

1. Find foreign keys

SELECT * FROM sys.foreign_keys WHERE referenced_object_id = object_id(‘Student‘)

2. Delete foreign keys

SELECT     ‘ALTER TABLE ‘ +  OBJECT_SCHEMA_NAME(parent_object_id) +    ‘.[‘ + OBJECT_NAME(parent_object_id) +     ‘] DROP CONSTRAINT ‘ + nameFROM sys.foreign_keysWHERE referenced_object_id = object_id(‘Student‘)

Could not drop object 'student' because it is referenced by a FOREIGN KEY constraint

标签:foreign key   drop table   

原文地址:http://blog.csdn.net/jcx5083761/article/details/39891041

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!