@@ERROR
will be populated as soon as an error occurs but if there is another statement executing after the error occurred @@ERROR
will reset its value to NULL
, so anticipating where an error can possibly occur and storing its values to a variable etc. etc. seems a lot of hassle.
Where as if you are making use of TRY...CATCH
block, as soon as an error occurs in the TRY
block your control jumps to the CATCH
block and and you can make use of the system Error Functions , which can give you detailed information about the error. If no error occurs then the control never enters the CATCH
block.
Some of them system error functions are:
ERROR_LINE()
EROR_MESSAGE()
ERROR_Severity()
ERROR_PROCEDURE()
ERROR_STATE()
Therefore I personally think using TRY...CATCH
makes your life a lot easier as a developer.