here's my code, which is designed to generate an error:
-- =================================================
DECLARE @ErrNum INT
DECLARE @Msg INT
SET @Msg = 'TEXT'
SET @ErrNum = @@ERROR
IF @ErrNum <> 0
PRINT 'An error occurred and is being handled gracefully.'
ELSE
PRINT 'No errors occured.'
-- =================================================
Execution never reaches the line which gets the value from @@ERROR. WHY??? What's the point in having @@ERROR if you can never read it?
-- =================================================
DECLARE @ErrNum INT
DECLARE @Msg INT
SET @Msg = 'TEXT'
SET @ErrNum = @@ERROR
IF @ErrNum <> 0
PRINT 'An error occurred and is being handled gracefully.'
ELSE
PRINT 'No errors occured.'
-- =================================================
Execution never reaches the line which gets the value from @@ERROR. WHY??? What's the point in having @@ERROR if you can never read it?