BEGIN   TRANSACTION 
语句
if @@error<>0
rollback TRANSACTION 
else
COMMIT TRANSACTION 事坞

解决方案 »

  1.   

    create table a(id int identity(1,1),title char(10),body char(10),samllid int) 
    create table b(id int identity(1,1),title char(10),body char(10),tableid int)
    gocreate trigger triggername
    on a
    instead of insert
    as   insert into a(title,body,samllid) select title,body,samllid from inserted
       insert into b select title,body,@@identity from insertedgoinsert into a select '1,','1',1select * from b
    /*
    id          title      body       tableid     
    ----------- ---------- ---------- ----------- 
    1           1,         1          1(所影响的行数为 1 行)
    */
    drop table a,b