[转帖]跨表触发器的写法
<span class="tpc_content">EX:有kqrb 这个表,jb这个表<br/>如果jb加班单时间<=jbsj,jbsj=加班单时间<br/>如果jb加班单时间>jbsj,jbsj=jbsj<br/><br/><br/>create trigger kq_tr on kqrb <br/>for insert<br/>as<br/><br/>declare @xbh int,@xrq datetime,@xb char(2),@sj4 datetime<br/>declare @qjsj datetime,@xxbh int<br/>select @xbh=bh,@xrq=rq,@xb=xb from inserted<br/>select @qjsj=qjsj,@xxbh=bh from jb --where @xxbh=bh<br/><br/>begin<br/>if @xb in('01') and (datepart(hh,@sj4)+datepart(mm,@sj4)/60-18)>=0.5<br/>update kqrb set jbsj=jbsj-'1900-00-00 00:30:00.000' where bh=@xbh and rq=@xrq<br/>end</span><br/>
页:
[1]