What is @@ERROR in SQL Server? Interview Question
@@ERROR as one of the basic error handling mechanisms in SQL Server. @@ERROR is a Global Variable in SQL Server. This variable automatica...

https://www.interviewquestionspdf.com/2016/04/what-is-error-in-sql-server-interview.html
@@ERROR as one of the basic error handling mechanisms in SQL Server. @@ERROR is a Global Variable in SQL Server. This variable automatically populates the error message when a certain error occurred in any statement. But we have to trace it within just after the next line where the actual error occurred, otherwise, it will reset to 0.