TheBugSlayer
Programmer
Hello fellows.
We have a SP that used to look like this:
Now someone says the individual statements were taking too long, no matter what improvements they tried to implement, so they decided to enclose each statement within a transaction like this:
Stemming from the above, my questions are:
1- In the original SP, in terms of transactions, are the individual UPDATE statements executed implicitly inside ONE transaction (the stored procedure)? In other words, I am trying to understand how a delay or failure in UPDATE 1 affects UPDATE 2.
2- Does it really represent any improvement to group the individual statements in a transaction? Wouldn't the code still execute in a sequential manner?
Thank you for your answers.
MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
We have a SP that used to look like this:
Code:
CREATE PROC [dbo].[pSomeName]
AS
UPDATE Table1...
UPDATE Table2...
...
UPDATE TableN
Now someone says the individual statements were taking too long, no matter what improvements they tried to implement, so they decided to enclose each statement within a transaction like this:
Code:
CREATE PROC [dbo].[pSomeName]
AS
BEGIN TRAN;
UPDATE Table1...
COMMIT TRAN;
BEGIN TRAN;
UPDATE Table2...
COMMIT TRAN;
...
BEGIN TRAN;
UPDATE TableN
COMMIT TRAN;
Stemming from the above, my questions are:
1- In the original SP, in terms of transactions, are the individual UPDATE statements executed implicitly inside ONE transaction (the stored procedure)? In other words, I am trying to understand how a delay or failure in UPDATE 1 affects UPDATE 2.
2- Does it really represent any improvement to group the individual statements in a transaction? Wouldn't the code still execute in a sequential manner?
Thank you for your answers.
MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)