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

解决外键无法删除问题

时间:2017-04-26 12:55:48      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:reference   tty   sel   ack   const   schema   app   问题   span   

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

解决外键无法删除问题

标签:reference   tty   sel   ack   const   schema   app   问题   span   

原文地址:http://www.cnblogs.com/kevin1988/p/6767824.html

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