SQL insert into 出现重复约束,不让插入,如何去掉?

2024-12-25 13:30:59
推荐回答(1个)
回答1:

SELECT
tab.name AS [表名],
chk.name AS [Check约束名],
col.name AS [列名],
chk.definition
FROM
sys.check_constraints chk
JOIN sys.tables tab
ON (chk.parent_object_id = tab.object_id)
JOIN sys.columns col
ON (chk.parent_object_id = col.object_id
AND chk.parent_column_id = col.column_id)

你可以通过上面这个语句,看看 那个表里面, 有没有其他额外的 Check。

或者通过下面的这个语句,查询 那个表上面, 有没有什么触发器 限制了你的操作。

select
tri.name AS TriggerName,
tri.is_disabled AS IsDisable,
tri.is_instead_of_trigger AS IsInsteadOfTrigger,
c.text AS CreateTriggerSQL
from
sys.triggers tri LEFT OUTER JOIN
dbo.syscomments c ON tri.object_id = c.id