日期:2014-05-18 浏览次数:20560 次
--主站触发器(INSERT USER) create trigger tr_insert_User on [ZJ_User] for insert as set xact_abort on alter table srv2.sqldata02.dbo.Dv_User disable trigger all--禁用论坛表触发器,为防止2个表插入死循环 insert srv2.sqldata02.dbo.Dv_User (UserName,UserPassword,UserEmail,UserSex,JoinDate,LastLogin,UserLogins,UserBirthday,UserQuesion,UserAnswer,UserLastIP,LastIPInfo) select UserName,UserPassword,UserEmail,UserSex,JoinDate,LastLogin,UserLogins,UserBirthday,UserQuesion,UserAnswer,UserLastIP,LastIPInfo from inserted alter table srv2.sqldata02.dbo.Dv_User enable trigger all--启用论坛表触发器 go --主站触发器(UPDATE USER) create trigger tr_update_User on [ZJ_User] for update as set xact_abort on alter table srv2.sqldata02.dbo.Dv_User disable trigger all--禁用论坛表触发器 update srv2.sqldata02.dbo.Dv_User set UserPassword=i.UserPassword,UserEmail=i.UserEmail,UserSex=i.UserSex,JoinDate=i.JoinDate,LastLogin=i.LastLogin,UserLogins=i.UserLogins,UserBirthday=i.UserBirthday,UserQuesion=i.UserQuesion,UserAnswer=i.UserAnswer,UserLastIP=i.UserLastIP,LastIPInfo=i.LastIPInfo from srv2.sqldata02.dbo.Dv_User,inserted i,deleted d where i.[UserName]=d.[UserName] and i.[UserName]=srv2.sqldata02.dbo.Dv_User.[UserName] alter table srv2.sqldata02.dbo.Dv_User enable trigger all--启用论坛表触发器