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