SQL Server : stored procedure transaction

Viewed 77168

Hello I got some stored procedures to create products and other stuff on my site. Now I have to run some of them in a transaction. Is that possible or do I have to make a stored procedure only for the transaction?

Can I say something like

BEGIN TRAN
"1. stored procedure"
"2. stored procedure"
COMMIT
4 Answers
Begin TRAN
BEGIN TRY
  -- your Action
  Commit TRAN
END TRY
BEGIN CATCH
  IF @@TRANCOUNT > 0
  BEGIN
    ROLLBACK TRAN
  END 
END CATCH
Related