我有兩個表(表1,表2)和表1中的Id是表2中的外鍵。兩個表都有刪除更新其他表的觸發器(表3)。在表2上刪除Table1級聯刪除。當我在表2觸發MS SQL最佳執行計劃編譯中止到期超時
SQL Server parse and compile time:
CPU time = 391 ms, elapsed time = 10726 ms.
StatementOptmEarlyAbortReason="TimeOut"
執行
delete from Table1
where Table4Id = @table4Id
我'讓編纂超時在刪除觸發器表1從
UPDATE table3
SET table3.Column1 = NULL
FROM Table3 AS table3
JOIN DELETED AS deleted ON deleted.Table4Id = table3.Table4Id
WHERE deleted.Column1 = 1
上的Delete鍵觸發從表2可以
UPDATE table3
SET table3.Column1 = NULL
FROM Table1 AS table1
JOIN DELETED AS deleted on deleted.Table1Id = table1.Id
JOIN Table3 AS table3 ON deleted.Table3Id = table3.Id
WHERE table1.Column1 = 1 AND table1.Table4Id = table3.Table4Id
有沒有辦法擺脫這種編譯超時?
我想這可能是因爲你的級聯刪除你強制刪除觸發器更新同一個事務中同一個表中的同一個字段。兩個觸發器都試圖鎖定它來更新它,但必須相互等待。執行刪除語句的 – GuidoG
不會編譯任何內容。當你從「table1刪除...」中按F5時,或者當你在「create trigger ...」上按F5時,你會得到錯誤嗎? – GuidoG
我收到這個超時,當我按F5「從表1中刪除...」 – pokrz26