I have got a stored procedure in SQL Server 2008 and it does quite a fair amount of inserting / deleting / updating operations.
Now I am wondering if there would be any way that I might be able to detect whether or not a stored procedure has completed ALL Inserting / Deleting / Updating operations.
Also, I understand that there can be a returned value from a stored procedure, which in this case here can be a statusCode (0/1). But through some of my experiments, I found that the statusCode always would get returned immediately once the execution of the stored procedure was finished, while in the mean time, inserting / deleting / updating was actually still running. So what should I do here to see the statusCode only get returned when inserting / deleting / updating operations have all been completed?
Thanks.
Code Structure:
BEGIN
DECLARE @statusCode
SET @statusCode = 0
-- Loop through all tables in a given database
-- using cursor
-- do Insert / Update/ Delete operations
SET @statusCode = 1
SELECT @statusCode
END
If the stored procedure returns, all operations for that call are complete.
You have not seen operations continuing after a stored procedure finishes unless another connection is making changes too. For one, it would break A in ACID