I am using context_info to simulate a global variable, I use it in this context.
I have scripts made up of several batches, I set a global variable at the beginning (123
in the example) and then after all the batches I use that number to populate a log table.
Now this works, but today it failed on one machine, I cannot figure why. Is there a reason why context_info should not work? I tried to manually replace context_info
with 123
and the script was succesful. The script was run from a Delphi application.
DECLARE @GlobalInteger binary(128)
SET @GlobalInteger =cast(123 as binary(128))
SET CONTEXT_INFO @GlobalInteger
GO
BATCH 1
GO
...
BATCH N
GO
INSERT INTO TABLE_LOG VALUES (cast(context_info() as INT)