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 是判断是否有改变的列

posted @ 2014-03-12 15:19  batter152  阅读(239)  评论(0编辑  收藏  举报