Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 simple procedure question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-06-13 : 10:52:38
harvinder writes "Hi,

If we run procedure without having explicit begin/commit tran inside procedure does it commit the data itself after execution is finished or the code that
calls procedure has to explitily commit or rollback?
If yes then what is use of begin/commit tran inside procedure except error handling?

Thanks
--Harvinder"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-06-13 : 20:36:46
If your server has SET IMPLICIT_TRANSACTIONS ON, you would need to issue an explicit COMMIT even without an explicit BEGIN TRANSACTION. I believe that this setting defaults to OFF, but I believe the server can be configured to set it ON as a default for all new connections.

You don't have to use transactions for error handling at all, they are only intended to treat multiple statements as one unit of work, that can be rolled back or committed as such. Unless you specify a BEGIN TRAN or implicit transaction, each statement is itself a transaction and is committed as it executes. You would not be able to roll back an individual statement without using transactions.

Go to Top of Page
   

- Advertisement -