How does SQL Server treat statements inside stored procedures with respect to transactions?

后端 未结 3 1861
有刺的猬
有刺的猬 2021-02-06 20:52

Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and DELETE statements. There is no explicit BEGIN TRANS / COMMIT TRANS / ROLLBACK TRANS logic

3条回答
  •  感情败类
    2021-02-06 21:31

    You can find out on your own by creating a small stored procedure that does something simple, say insert a record into a test table. Then Begin Tran; run sp_test; rollback; Is the new record there? If so, then the SP ignores the outside transaction. If not, then the SP is just another statement executed inside the transaction (which I am pretty sure is the case).

提交回复
热议问题