BEGIN
BEGIN TRY --Start the Try Block..
BEGIN TRANSACTION -- Start the transaction..END TRY
UPDATE MyChecking SET Amount = Amount - @AmountCOMMIT TRAN -- Transaction Success!
WHERE AccountNum = @AccountNumUPDATE MySavings SET Amount = Amount + @Amount
WHERE AccountNum = @AccountNum
BEGIN CATCH
ROLLBACK TRAN --RollBack in case of Error
-- you can Raise ERROR with RAISEERROR() Statement including the details of the exception
ENDRAISERROR(ERROR_MESSAGE(), ERROR_SEVERITY(), 1)END CATCH
No comments:
Post a Comment