首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

想写一个修改触发器。请各位大神帮帮小弟我

2012-08-13 
想写一个修改触发器。。。请各位大神帮帮我CREATE TRIGGER [JU_Uint_People_XueliAndZhichengUpdate] ON [dbo

想写一个修改触发器。。。请各位大神帮帮我
CREATE TRIGGER [JU_Uint_People_XueliAndZhichengUpdate] ON [dbo].[JU_Unit_People] 
FOR UPDATE 
AS
IF UPDATE(xueli)
begin
INSERT INTO JU_People_Record(ysxl,id_rl) values(Deleted.xueli,Deleted.id_rl)
end
IF UPDATE(ZhiCheng)
begin
INSERT INTO JU_People_Record(yszc,id_rl) values(Deleted.ZhiCheng,Deleted.id_rl)
end


这是代码 想实现的是 当JU_Unit_People的 xueli和 ZhiCheng字段发生修改时触发 但是提示我这里不能用列名。。触发器真不懂 请大神们帮帮我

[解决办法]
CREATE TRIGGER [JU_Uint_People_XueliAndZhichengUpdate] ON [dbo].[JU_Unit_People]
FOR UPDATE
AS
IF UPDATE(xueli)
begin
INSERT INTO JU_People_Record(ysxl,id_rl) select xueli,id_rl from Deleted
end
IF UPDATE(ZhiCheng)
begin
INSERT INTO JU_People_Record(yszc,id_rl) select ZhiCheng,id_rl from Deleted
end

热点排行