Re: Store Proc Question

From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 11/09/04


Date: Tue, 9 Nov 2004 23:20:33 -0000

CREATE PROC usp_foo
AS

BEGIN TRAN

 INSERT ...
 IF @@ERROR <> 0 GOTO err

 UPDATE ...
 IF @@ERROR <> 0 GOTO err

COMMIT TRAN

SELECT ...

GOTO done

err:
ROLLBACK TRAN

done:
RETURN

-- 
David Portas
SQL Server MVP
--


Relevant Pages

  • Re: Server: Msg 170, Level 15, State 1
    ... add add commas to seperate the paramters. ... Remove the OUTPUT clause, unless you really intend to pass back a ... COMMIT TRAN ... Hugo Kornelis, SQL Server MVP ...
    (microsoft.public.sqlserver.mseq)
  • Re: Avoid update without where clause
    ... > BEGIN TRAN ... > <some select statements to verify your DML code> ... > Mark Allison, SQL Server MVP ... > Donald wrote: ...
    (microsoft.public.sqlserver.server)
  • Re: Avoid update without where clause
    ... >> Donald, ... >> BEGIN TRAN ... >> production, even if they have been scripted and tested. ... >> Mark Allison, SQL Server MVP ...
    (microsoft.public.sqlserver.server)
  • Re: Massive TRAN ...COMMIT block
    ... > raiserror ... > COMMIT TRAN ... you may never get to the rollback tran in this ... Now, deadlocks are another issue, but more or less, unless they are really ...
    (microsoft.public.sqlserver.programming)
  • Re: pbm with begin tran
    ... > ROLLBACK TRAN ... >> Here is one problem with BEGIN TRAN AND COMMIT TRAN ... >> CREATE PROCEDURE BookSeat ...
    (microsoft.public.sqlserver.programming)