我的表结构类似于项目代码,大小,袖子,项目。所以人们在插入数据时会输入'S0001','F','96'等数据插入我需要插入项目字段数据,如'S0001-f-96'我如何编写触发器。
答案 0 :(得分:0)
创建TRIGGER [dbo]。[name] ON [dbo]。[table] 对于INSERT 如 声明@Itemcode varchar(30); 声明@Itemname varchar(40); 声明@Slv varchar(1); 声明@Createdate datetime; 声明@audit_action varchar(100);
select @Itemcode=i.ItemCode from inserted i;
select @Itemname=i.ItemName from inserted i;
select @Slv =i.U_SLV from inserted i;
select @Createdate =i.Createdate from inserted i;
set @audit_action='Inserted Record -- After Insert Trigger.';
update OITM_CLONE set sapitem =@Itemcode+'-'+@Slv where itemcode=@Itemcode and u_slv=@Slv and Createdate=@Createdate;
PRINT 'AFTER INSERT trigger fired.'
这是对的吗?