SQL Server/T-SQL Tutorial/System Settings/ERROR NUMBER

Материал из SQL эксперт
Перейти к: навигация, поиск

ERROR_NUMBER functions

7> BEGIN TRY
8>     SELECT CONVERT(int, "ABC") AS ConvertException
9> END TRY
10> BEGIN CATCH
11>     IF ERROR_NUMBER() = 123
12>         SELECT "Error 123"
13>     ELSE
14>         SELECT ERROR_NUMBER() AS ErrorNumber
15> END CATCH
16> GO
ConvertException
----------------
(0 rows affected)
ErrorNumber
-----------
        245
(1 rows affected)