触发器问题,insert行时,把b字段值赋值给a字段(200)

  • 主题发起人 主题发起人 小師妹
  • 开始时间 开始时间
例如insert tb(a,b) values(1,2),需触发器把a的值1该为2.
 
Create trigger Tb_Insert on tb instead of insert as insert tb(a, b) values (inserted.b, inserted.a)
 
谢谢!create trigger chb_tirg_1 on wk_contractafter insertasbeginupdate wk set wk.famount=i.fcontractcost from wk_contract wk,inserted i where wk.fcontractNumber=i.fcontractNumberend
 
create trigger chb_tirg_1 on wk_contractafter insertasbeginupdate wk set wk.famount=i.fcontractcost from wk_contract wk,inserted i where wk.fcontractNumber=i.fcontractNumberend
 
Create trigger Tb_Ins on tbinstead of insert as begin Set nocount on; declare @A int, @B int set @A = (Select a from inserted) set @B = (Select b from inserted) insert into tb(a, b) values (@B, @A)end
 
哦, 你比我快啊我也顺便学习了一下,呵呵
 
Create trigger Tb_Insert on tb instead of insert as insert tb(a, b)(select b, a from inserted)
 
后退
顶部