Using GOTO instead sql query statement.
SET @vcMessage = 'Go to cleanup';
GOTO Cleanup;
---------------------------------------------------------------
-- Cleanup
---------------------------------------------------------------
Cleanup:
--Logging
SET @vcMessage = 'Completed' + CASE WHEN @iReturnCode = 0 THEN ' successfully.' ELSE ' with errors.' END;
RETURN @iReturnCode;
Comments