SQL Server : stored procedure transaction

前端 未结 4 1414
时光说笑
时光说笑 2020-12-28 15:45

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 st

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-28 16:02

    Begin TRAN
    BEGIN TRY
      -- your Action
      Commit TRAN
    END TRY
    BEGIN CATCH
      IF @@TRANCOUNT > 0
      BEGIN
        ROLLBACK TRAN
      END 
    END CATCH
    

提交回复
热议问题