create trigger tr_同步 on 表名 for update,delete asinsert into 目标表(字段列表) select 字段列表 from deleted go
现在要求有些变化:当源表发生修改、插入和删除操作时,触发器被启动,调用相应的存储过程,将源表发生的操作还原为SQL语句(比如,源表为tb_Employee,它所对应的目标表为TGtb_Employee,向源表tb_Employee中插入一条记录,如insert into tb_Employee values(?,?,?,?),那么还原后的SQL语句可能为insert into TGtb_Employee values(?,?,?,?),然后将还原的sql存储在一个文本文件中,怎么实现呢?
for update,delete
asinsert into 目标表(字段列表)
select 字段列表
from deleted
go