What is @@ERROR in SQL? @@ERROR returns only current error information (error number and error) after T-SQL statements executed. @@ERROR returns 0, if the previous SQL statement has no errors otherwise return 1. @@ERROR is used in basic error handling in SQL Server and @@ERROR is a global variable of SQL and this @@ERROR variable automatically handle by SQL. If error is occurred set error number otherwise reset 0. It is work only within the current scope and also contains the result for the last operation only. Syntax : - @@ERROR Return Type : - INT When we should use @@ERROR? 1. While executing any stored procedures 2. In the SQL statements like Select, Insert, Delete and Update etc. 3. In the Open, Fetch Cursor. When we should use Try Catch Block? The Try Catch Block is generally used where want to catch errors for multiple SQL statements. ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers