Error Handling

  • Is there an equivalent of @@ERROR for the error messages? I need to return the error message along with the error number to the client application.

    Also, I was going through BOL and I did not understand what is 'state' used for?

    Will SQL Server consider an error message with severity level say 2 any different than one with say 12. I am talking about user defined error messages.

    Thanks a lot for your time folks

  • quote:


    Is there an equivalent of @@ERROR for the error messages?


    I wish there was, but no, I haven't been able to capture the formatted message... at least not in T-SQL. Others though may have a method.

    quote:


    Also, I was going through BOL and I did not understand what is 'state' used for?


    I've been using SQL Server for nigh on 6 years and I don't know what use 'state' is either. I'm keen to learn of instances where it can be used.

    quote:


    Will SQL Server consider an error message with severity level say 2 any different than one with say 12.


    Yes it does.

    For example, create a 1-step job with a t-sql step of:

     
    
    raiserror('My Error Message',10,1)

    Run the job and it should succeed.

    Change the severity from 10 to 11 and rerun. The higher severity should fail the step and the job.

    Cheers,

    - Mark

    Edited by - mccork on 08/21/2003 10:51:51 PM


    Cheers,
    - Mark

  • Please follow this link and check if this helps you out.

    http://www.developer.com/tech/article.php/724711

    Pay Respect to People on your way up. For you will meet the same People on your way down.


    He who knows others is learned but the wise one is one who knows himself.

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

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