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
This function returns the severity value of the error where an error occurs, if that error caused the CATCH block of a TRY...CATCH construct to execute.
When called in a CATCH block where an error occurs, `ERROR_SEVERITY` returns the severity value of the error that caused the `CATCH` block to run.
41
-
42
-
`ERROR_SEVERITY` returns NULL if called outside the scope of a CATCH block.
43
-
44
-
## Remarks
45
-
`ERROR_SEVERITY` supports calls anywhere within the scope of a CATCH block..
46
-
47
-
`ERROR_SEVERITY` returns the error severity value of an error, regardless of how many times it runs or where it runs within the scope of the `CATCH` block. This contrasts with a function like @@ERROR, which only returns an error number in the statement immediately following the one that causes an error.
48
-
49
-
`ERROR_SEVERITY` typically operates in a nested `CATCH` block. `ERROR_SEVERITY` returns the error severity value specific to the scope of the `CATCH` block that referenced that `CATCH` block. For example, the `CATCH` block of an outer TRY...CATCH construct could have an inner `TRY...CATCH` construct. Inside that inner `CATCH` block, `ERROR_SEVERITY` returns the severity value of the error that invoked the inner `CATCH` block. If `ERROR_SEVERITY` runs in the outer `CATCH` block, it returns the error severity value of the error that invoked that outer `CATCH` block.
50
-
51
-
## Examples: [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)]
52
-
53
-
### A. Using ERROR_SEVERITY in a CATCH block
54
-
This example shows a stored procedure that generates a divide-by-zero error. `ERROR_SEVERITY` returns the severity value of that error.
55
-
56
-
```sql
57
-
BEGIN TRY
58
-
-- Generate a divide-by-zero error.
59
-
SELECT1/0;
60
-
END TRY
61
-
BEGIN CATCH
62
-
SELECT ERROR_SEVERITY() AS ErrorSeverity;
63
-
END CATCH;
64
-
GO
28
+
This function returns the severity value of the error where an error occurs, if that error caused the `CATCH` block of a `TRY...CATCH` construct to execute.
When called in a `CATCH` block where an error occurs, `ERROR_SEVERITY` returns the severity value of the error that caused the `CATCH` block to run.
45
+
46
+
`ERROR_SEVERITY` returns `NULL` if called outside the scope of a `CATCH` block.
47
+
48
+
## Remarks
49
+
50
+
`ERROR_SEVERITY` supports calls anywhere within the scope of a `CATCH` block.
51
+
52
+
`ERROR_SEVERITY` returns the error severity value of an error, regardless of how many times it runs or where it runs within the scope of the `CATCH` block. This contrasts with a function like [@@ERROR](error-transact-sql.md), which only returns an error number in the statement immediately following the one that causes an error.
53
+
54
+
`ERROR_SEVERITY` typically operates in a nested `CATCH` block. `ERROR_SEVERITY` returns the error severity value specific to the scope of the `CATCH` block that referenced that `CATCH` block. For example, the `CATCH` block of an outer `TRY...CATCH` construct could have an inner `TRY...CATCH` construct. Inside that inner `CATCH` block, `ERROR_SEVERITY` returns the severity value of the error that invoked the inner `CATCH` block. If `ERROR_SEVERITY` runs in the outer `CATCH` block, it returns the error severity value of the error that invoked that outer `CATCH` block.
55
+
56
+
## Examples: Azure Synapse Analytics and Analytics Platform System (PDW)
57
+
58
+
### A. Use ERROR_SEVERITY in a CATCH block
59
+
60
+
This example shows a stored procedure that generates a divide-by-zero error. `ERROR_SEVERITY` returns the severity value of that error.
0 commit comments