创建触发器

if (object_id('tr_wuliu_rk_mx', 'tr') is not null)    
drop trigger tr_wuliu_rk_mx
go 
CREATE TRIGGER tr_wuliu_rk_mx  ON [dbo].[wuliu_rk_mx] 
FOR INSERT, UPDATE, DELETE 
as
declare @tzdbh varchar(100) 
declare @yeartype  varchar(100)
declare @seasontype  varchar(100)
 
--更新时
if update(seasontype)
begin
select @tzdbh =tzdbh ,@yeartype =yeartype,@seasontype =seasontype from inserted 
update wuliu_rk_mx set seasontype='春季' where tzdbh=@tzdbh and ltrim(rtrim(yeartype))='2015' and ltrim(rtrim(seasontype))='秋季'
end

 

posted @ 2014-12-04 10:16  wangmeihong  阅读(124)  评论(0编辑  收藏  举报