Yes it is. Just remember that the value of @@ERROR changes every time
another operation takes place, so if you need to save the value of @@ERROR
to track down the problem, move it to another variable before executing
another statement!
-----Original Message-----
From: Fang, Elaine [mailto:Elaine.[Email Address Removed] Wednesday, July 10, 2002 7:27 PM
To: [Email Address Removed] Can I do sth like this in T-SQL?
Hi list,
In my T-SQL code, can I do
...
IF @@error <> 0
GOTO ERREXIT1
(OTHER CODE)
ERREXIT1:
PRINT ('Error inserting value to xx table')
GOTO ERREXIT2
(MORE CODE)
ERREXIT2:
PRINT('Fatal error: migration failed')
-- end of file
I'd like to have multiple places to do error handling since some of the
errors won't affect subsequent code segments thus the execute can continue,
while others are fatal and thus need to exit the whole file (go to
errexit2).
Is that legal?
Thanks,
Elaine
---------------------------------------------------------------------
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page