请教一个触发器的写法 表结构 id和count两个字段前台程序会有update语句 update table1 set count = count+1 来修改这个表中的数据我想做个触发器,如果修改了表中id值为1,2,3这3条纪录的count值,就ROLLBACK TRANSACTION,请问触发器该怎么写?非常感谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 create trigger tu_表 on 表for updateasif update([count]) and exists(select 1 from inserted i where i.id in (1,2,3))begin rollback tran returnend Create trigger trgname on 表for updateas if (update(count)) and (exists(select * from 表 where id between 1 and 3)) Rollback trango Create trigger trgname on 表for updateas if (update(count)) and (exists(select * from Inserted where id between 1 and 3)) Rollback trango 关于联表查询的一个问题 帮忙看看下面的SQL语句什么意思. xp_sendmail怎么发送多个查询生成的附件 一个基于集合查询的问题 decimal类型字段疑惑 请问使用as后WHERE该怎么写? SQL 怎么写存储过程? 关于C++char数组用存储过程插入数据到SQL Server中 菜鸟问题,insert into与insert有什么区别? 如何把一张表的记录加到另外一张表中,两张表的字段不同,也就是合并记录,不是追加 关于SQL中插入的问题 提高数据性能的问题
for update
as
if update([count]) and exists(select 1 from inserted i where i.id in (1,2,3))
begin
rollback tran
return
end
for update
as
if (update(count)) and (exists(select * from 表 where id between 1 and 3))
Rollback tran
go
for update
as
if (update(count)) and (exists(select * from Inserted where id between 1 and 3))
Rollback tran
go