You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example uses `@@ERROR` to check for a check constraint violation (error #547) in an `UPDATE` statement.
54
54
55
-
```
55
+
```sql
56
56
USE AdventureWorks2012;
57
57
GO
58
58
UPDATEHumanResources.EmployeePayHistory
@@ -66,7 +66,7 @@ GO
66
66
### B. Using @@ERROR to conditionally exit a procedure
67
67
The following example uses `IF...ELSE` statements to test `@@ERROR` after an `DELETE` statement in a stored procedure. The value of the `@@ERROR` variable determines the return code sent to the calling program, indicating success or failure of the procedure.
68
68
69
-
```
69
+
```sql
70
70
USE AdventureWorks2012;
71
71
GO
72
72
-- Drop the procedure if it already exists.
@@ -101,7 +101,7 @@ GO
101
101
### C. Using @@ERROR with @@ROWCOUNT
102
102
The following example uses `@@ERROR` with `@@ROWCOUNT` to validate the operation of an `UPDATE` statement. The value of `@@ERROR` is checked for any indication of an error, and `@@ROWCOUNT` is used to ensure that the update was successfully applied to a row in the table.
103
103
104
-
```
104
+
```sql
105
105
USE AdventureWorks2012;
106
106
GO
107
107
IF OBJECT_ID(N'Purchasing.usp_ChangePurchaseOrderHeader',N'P')IS NOT NULL
0 commit comments