The TSQL BEGIN TRY and BEGIN CATCH block pattern does not catch errors due to a lost client connection. How can I catch and handle a lost client connection?
I'm setting a flag that indicates processing while processing a loop of individual transactions and the catch block re-sets that flag on error, but if the client connection is lost, my catch block does not execute...
PSUEDOCODE:
BEGIN TRY
SET FlagToIndicateProcessing = 1
LOOP START
BEGIN TRANS
DO WORK
COMMIT TRANS
LOOP END
SetSomeValues
SET FlagToIndicateProcessing = 0
END TRY
BEGIN CATCH
SetSomeValues
SET FlagToIndicateProcessing = 0
END CATCH