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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server Best Practice

Status
Not open for further replies.

MastermindSQL

Technical User
Aug 12, 2005
11
US
What is the difference between the following two cases:

Case 1:

CREATE PROC MyProc
AS
.....
RETURN
GO
----------
BEGIN TRAN
EXEC MyProc
COMMIT

===================
Case 2:

CREATE PROC MyProc
AS
BEGIN TRAN
.....
COMMIT
RETURN
GO
----------
EXEC MyProc

Which one of the above is a good practice and how the locks are handled (if there is any difference) in each case.

Thanks in advance.



 
Case 2 probably. It will still behave transactional even if you forget to wrap EXEC into transaction. Plus BEGIN/END TRAN get compiled that way.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top