在Sql Server触发器中判断操作是Insert还是Update还是Delete
1个回答
2017-08-19
展开全部
在Sql Server触发器中判断操作是Insert还是Update还是Delete
if exists(select 1 from inserted)
begin
if exists(select 1 from deleted)
begin
select @action = 'Update'
end
else
begin
select @action = 'Insert'
end
end
else if exists(select 1 from deleted)
begin
select @action = 'Delete'
end
if exists(select 1 from inserted)
begin
if exists(select 1 from deleted)
begin
select @action = 'Update'
end
else
begin
select @action = 'Insert'
end
end
else if exists(select 1 from deleted)
begin
select @action = 'Delete'
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询