Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transactions in stored procedures

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I have simple stored procedures which have a single update or insert statements. In some cases I have a select followed by insert or update.
Is it necessary to use begin tran & commit tran in these cases ?

Is there a overhead to using begin tran & commit ?
Thanks for your time
 
Hiya,

It is not strictly necessary to use BEGIN and COMMIT TRANSACTION commands for what you are doing, and stored procedures will do an implicit COMMIT when they complete.

However, it is always a good idea to commit as it clears down the transaction log of any data, and it means that should the server hit a problem, your changes are not lost.

Overhead time is minimal in using these, and more than made up in the event of server problems.

Tim
 
Guys

Please be aware a commit transaction does not clear down the transaction log. The only way the transaction log is cleared down is by the following methods:

1) If you have the trunc. log on chkpt option set.

2) Using the BACKUP LOG SQL command with appropriate parameters.

Both these methods will remove the inactive portion of the transaction log and must be used as part of your database maintenance strategy.

Rick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top