Error Message

  • Initially I coded Restore Database in a TRY CATCH BLOCK.

    The ERROR_MESSAGE() is collecting/showing the "RESTORE DATABASE is terminating abnormally".

    When I execute Restore Database command in managmenet studio I get these following messages.

    Msg 3257, Level 16, State 1, Line 1

    There is insufficient free space on disk volume 'D:\' to create the database. The database requires 73002319872 additional free bytes, while only 67640401920 bytes are available.

    Msg 3119, Level 16, State 4, Line 1

    Problems were identified while planning for the RESTORE statement. Previous messages provide details.

    Msg 3013, Level 16, State 1, Line 1

    RESTORE DATABASE is terminating abnormally.

    How do I collect all the three messages in TSQL in CATCH BLOCK.

    Thanks.

  • The first two messages are lower level messages that are not a part of the TSQL statement, but are occurring at a lower level within the system. The CATCH statement is only able to catch the higher level message. See the example in BOL with the syntax error within a stored procedure.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I know this is an old post, but has this changed? I have not read anything on it. In most languages you have an Exception and an inner Exception. It would be very handle to have the inner exception in this case as I can make my script more fail-safe. Instead, I am not thinking about programming a service in .NET to handle what SQL scripting is not able to.

    Any thought or new concepts?

  • Basically if the error will cause a disconnect, SQL Server can't catch or handle the error, so the calling code will have to.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply