SQL Trigger


--update

if ((exists (select 1 from inserted)) and (exists (select 1 from deleted)))


--insert

else if (exists (select 1 from inserted) and not exists (select 1 from deleted))


--delete

else if (not exists (select 1 from inserted) and exists (select 1 from deleted))



判斷當前修改的某一列是否變化

if((select count(*) from inserted a inner join deleted b on a.ADAccount = b.ADAccount and a.IsDefaultScore <> b.IsDefaultScore)>0)

ADAccount 是主鍵

IsDefaultScore 是判斷是否有改變的列

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章