Meldung 3725, Ebene 16, Status 0, Zeile 327
The constraint 'UQ_users_email' is being referenced by table 'posts', foreign key constraint 'FK_posts_users'.
Meldung 3727, Ebene 16, Status 0, Zeile 327
Could not drop constraint. See previous errors.除了解析错误消息之外,我如何获得阻止某个约束的删除的所有约束的列表?
发布于 2016-02-25 08:34:55
PK/UQ FK依赖于引用表的(块拖放),它所依赖的列的任何类型的约束块删除。引用目标表的表列表可以由此查询列出:
select
object_schema_name(fk.fkeyid) + '.' + object_name(fk.fkeyid) as [REF_BY],
object_name(fk.constid) as [REF_NAME]
from sys.sysforeignkeys fk
inner join sys.sysconstraints cs on cs.constid = fk.constid
where fk.rkeyid = object_id('dbo.my_target_table_with_constraint_to_drop', 'u')
order by 1, 2所有这些FKs将阻止PK/UQ从目标表中删除。
https://stackoverflow.com/questions/35621068
复制相似问题