January 11, 2008 at 6:46 am
Hi All,
Hopefully a very simple question:
Stored procedures have a BEGIN and END statement around the entire contents of the stored proc. Does that mean that every TSQL statement within the stored proc is turned into a single transaction? If the stored proc contains 1 INSERT followed by 10 UPDATES on that table, will all the processing be taking place in the temp space rather than on the actual table with the results of the 1 INSERT and 10 UPDATES only being reflected in the actual table when that final END statement is reached?
Thanks, Alan.
January 11, 2008 at 7:39 am
No.
Begin != Begin transaction
Begin...End are just used to group code together. eg
IF (condition)
Begin
Do lots of things
End
Unless you explicitly begin a transaction, SQL works in autocommit, where each statement is in its own transaction and committed automatically once it finishes
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 11, 2008 at 7:48 am
Thanks for your prompt reply Gail. I suspected as much but didn't want to make a fool of myself without checking first!
January 11, 2008 at 9:22 pm
The real fact is, you don't need BEGIN/END in a stored procedure. Try it... it's just allowed to make die hard Oracle programmers happy 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply