Depressed, I want to convert a struct field into an int variable in the trigger. If an error occurs, set the variable to 0 and the result will always jump out when an error occurs, the @ error judgment is useless at all, so I searched the internet and found the SQL Server 2005 beta 2 Transact-SQL enhancement function in msdn. When talking about exception handling, I wrote the following:
SQL Server 2005 beta 2 introduces a simple but powerful exception handling mechanism in the form of try... catch Transact-SQL structure.
Earlier versions of SQL Server require that error handling be included after each statement suspected to be wrongCode. To combine the error check code, the label and the GOTO statement must be used. In addition, errors such as data type conversion errors may lead to the termination of batch processing; therefore, these errors cannot be captured using Transact-SQL. SQL Server 2005 beta 2 solves many of these problems.
It is now possible to capture and process errors that may lead to batch termination in the past, provided that these errors do not cause connection interruptions (usually errors with a severity of 21 or above, for example, suspicious table or database integrity, hardware errors, and so on ).
Reference URL: http://www.microsoft.com/china/MSDN/library/default.mspx? MFR = true
Uncomfortable ~~~~~~~~~