create trigger 触发器名称 on 对哪个表起作用
after insert,update
as
if @@rowcount =0 return
set nocount on
begin transaction; insert into 表名 (col1,col2,col3,...)
select inserted.col1,inserted.col2,inserted.col3,... inserted
where 语句
if @@error <>0
begin
raiserror(‘插入数据失败,数据库返回码:%d’,16,1,@@error)
rollback transaction;
return
end
commit transaction