CREATE TRIGGER 名1 ON dbo.tabMain
FOR INSERT
AS
insert tabSlave select * from insertedCREATE TRIGGER 名2 ON dbo.tabMain
FOR update
AS
update tabSlave set 列=aa.列 from inserted aa where aa.编号=db2..tabSlave.编号
CREATE TRIGGER 名3 ON dbo.tabMain
FOR delete
AS
delete tabSlave where 编号 in (select 编号 from deleted)
FOR INSERT
AS
insert tabSlave select * from insertedCREATE TRIGGER 名2 ON dbo.tabMain
FOR update
AS
update tabSlave set 列=aa.列 from inserted aa where aa.编号=db2..tabSlave.编号
CREATE TRIGGER 名3 ON dbo.tabMain
FOR delete
AS
delete tabSlave where 编号 in (select 编号 from deleted)
我的意思是我在TA1的YGBH字段中表中新增一个资料,在TB2中的ICKH字段中自动产生一个相应的值.
如:我新增一个YGBH = A00001 在TB2中得到ICKH= 10001
FOR INSERT
AS
insert TA2 (ICKH) select 10000+right(YGBH,5) from inserted