We can consider @@ERROR as one of the basic error handling mechanisms in SQL Server.
@@ERROR returns an error number if the previous statement encountered an error.
Returns 0 if the previous Transact-SQL statement encountered no errors.
Because @@ERROR is cleared and reset on each statement executed, check it immediately
following the statement being verified, or save it to a local variable that can be checked later.
Are you sure, @@Error returns the last occurred Error status/code (or) last executed TSQL statement ?
Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator