sql statement

The try catch statement in sql

BEGIN TRY

END TRY
BEGIN CATCH

END CATCH


sql throws an exception

RAISERROR (@ErrorMessage,
               @ErrorSeverity,
               @ErrorState
               );

           
@ErrorSeverity
            [0,10] within the closed interval, will not jump to catch;
            if it is [ 11, 19], jump to catch;
            if [20, infinity), terminate the database connection directly;

@ErrorState
            If the same user-defined error
            is raised in multiple locations, using a unique state number for each location helps Find the code snippet that throws the error.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326572950&siteId=291194637