sqlsever 抛出异常

BEGIN TRY
    RAISERROR ('Error raised in TRY block.', -- Message text.
, -- Severity.
 -- State.
               );
END TRY
BEGIN CATCH
    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT 
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

    RAISERROR (@ErrorMessage,  -- Message text.
               @ErrorSeverity, -- Severity.
               @ErrorState     -- State.
               );
END CATCH;


摘自: http://www.cnblogs.com/xugang/archive/2011/04/09/2010216.html

你可能感兴趣的:(sql)