When writing SQL transaction transactions, I often use @@ ERROR to find out if any problem occurred during the transaction or not. But I really don't know what are the advantages and disadvantages of handling exceptions with TRY ... CATCH, or which one is better. Please clarify the difference between those and the scenarios in which they are useful.
Thanks in advance, Vinu.
@@ERROR , , @@ERROR reset NULL, , .., , .
@@ERROR
NULL
TRY...CATCH, TRY, CATCH, , . , CATCH.
TRY...CATCH
TRY
CATCH
:
ERROR_LINE() EROR_MESSAGE() ERROR_Severity() ERROR_PROCEDURE() ERROR_STATE()
, TRY...CATCH , .
, , , - , :
error number for the last Transact-SQL statement executed.
TRY-CATCH
TRY-CATCH, , ERROR_MESSAGE() ERROR_NUMBER() .
, .