create trigger tr_T on T for insert,update as if exists(select 1 from inserted where C>120000) update 表 set C=1200000 from inserted i where 表.主键=i.主键 and i.C>120000 当字段A数字小于0,即当字段A变为负数时自动回滚字段A和字段B -------------------------- 这句话没看懂
create trigger tr_T on T for insert,update as if exists(select 1 from inserted where C>120000) update 表 set C=1200000 from inserted i where 表.主键=i.主键 and i.C>120000if exists(select 1 from inserted where A<0) and exists(select 1 from deleted) update 表 set A=d.A from inserted i,deleted d where 表.主键=i.主键 and i.主键=d.主键 and i.A<0 and exists(select 1 from deleted)
select 1 这个1是不是自己的表名??inserted i 这个i指的是那个表?系统临时生成的表??
for insert,update
as
if exists(select 1 from inserted where C>120000)
update 表
set C=1200000
from inserted i
where 表.主键=i.主键 and i.C>120000
当字段A数字小于0,即当字段A变为负数时自动回滚字段A和字段B
--------------------------
这句话没看懂
--------------------------
这句话没看懂=================================
比如现在A字段的值现在为20,由于某些原因使A字段的值变为了-1,这时能不能用触发器将A字段的值重新变为20,即是回滚.
for insert,update
as
if exists(select 1 from inserted where C>120000)
update 表
set C=1200000
from inserted i
where 表.主键=i.主键 and i.C>120000if exists(select 1 from inserted where A<0) and exists(select 1 from deleted)
update 表
set A=d.A
from inserted i,deleted d
where 表.主键=i.主键 and i.主键=d.主键
and i.A<0 and exists(select 1 from deleted)
这个1是不是自己的表名??inserted i
这个i指的是那个表?系统临时生成的表??