Error Messages with Severity 10 or lesser

  • Hi,

    Is there any way that we can capture Informational or Error messages with Severity 10 or lesser. I am able to capture the messages with Severity > 10 by using the TRY - CATCH block.

    For ExamplE:

    For the RESTORE VERIFYONLY function, I'm getting the following message:

    "The backup set on file 1 is valid."

    My aim is to raise this message on the Event log.

    Thanks,

    Harish.

  • Capture the value of @@error after the statement, then use raiserror to write it to the log.

  • The problem with that is " the @@Error automatically gets  converted to 0.

    Ex:

    Restore Verifyonly From Disk = 'D:\MSSQL\BACKUP\THURSDAY\xxxx.bak'

    PRINT

    @@Error

    OUTPUT:

    The backup set on file 1 is valid.

    0

     

     

    This is an information message, but I need to capture this message inorder to write to the Event log.

    Thanks,

    Harish.

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

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