I created a stored procedure with an insert like this:
CREATE PROCEDURE MyProcedure
... my Params ....
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO MyTable
....
Do some more stuff here
END
So now MyProcedure is called by another procedure somewhat like this:
BEGIN TRANSACTION
do some stuff ....
EXECUTE @return_value = MyProcedure
do some more stuff ...
IF(@return_value < 0)
BEGIN
ROLLBACK
END
With this setup, if there is an error in MyProcedure the rollback is executed and my insert is also rolled back. The problem is the INSERT is kind of a log for me to know what data got into MyProcedure.
I don’t know who is going to call MyProcedure in the future so it would be great to make sure that my INSERT is really happening even if the caller is doing a rollback. Is there anything i can do ?
lvoss is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.