首页 > 代码库 > 解决外键无法删除问题
解决外键无法删除问题
SELECT fk.name ,
fk.object_id ,
OBJECT_NAME(fk.parent_object_id) AS referenceTableName
FROM sys.foreign_keys AS fk
JOIN sys.objects AS o ON fk.referenced_object_id = o.object_id
WHERE o.name = ‘AppTag‘;
SELECT
‘ALTER TABLE ‘ + OBJECT_SCHEMA_NAME(parent_object_id) +
‘.[‘ + OBJECT_NAME(parent_object_id) +
‘] DROP CONSTRAINT ‘ + name
FROM sys.foreign_keys
WHERE referenced_object_id = object_id(‘AppInfo‘)
SELECT * FROM sys.foreign_keys WHERE referenced_object_id = object_id(‘Student‘)
http://stackoverflow.com/questions/1776079/sql-drop-table-foreign-key-constraint
解决外键无法删除问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。