SQL Server TRY CATCH FINALLY

前端 未结 6 2114
执笔经年
执笔经年 2021-02-06 23:09

I have a scenario where I need something similar to .NET\'s try-catch-finally block.

On my try, I will CREATE a #temp table, INSERT

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 23:29

    using custom error number to indicate there no real error, just final code?

    -- create temp table;
    BEGIN TRY
        -- use temp table;
        THROW 50555;
    END TRY
    BEGIN CATCH
        -- drop temp table;
        IF ERROR_NUMBER() <> 50555
            THROW;  -- rethrow the error
    END CATCH
    

提交回复
热议问题