CREATE PROCEDURE TEST
AS
BEGIN
begin trandelete from tablea--第一句if @@error=0    goto error
insert into tablea select * from tableb--第二句
if @@error=0    goto errordelete from tableb--第三句if @@error=0   goto error
    commit tran
goto saveend
:error
rollback tran
:saveendEND
GO