Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    6

    Unanswered: Error reporting customization

    Hi all,
    I was wandering if it is possible to customize the error messages in SQL Server 2005. I mean that I want to display some different infomation than those displayed when someone tries to enter a data that doesn't respect a rule in a table (for example a number instead of a string).
    Is it possible?

    Thanks million

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    You can add your own messages, and raise them with the RAISERROR command. I believe to add a custom error message, is sp_addmessage. the BOL article for RAISERROR should have a link to it.

  3. #3
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    or you declare a variable in your procs to hold the custom message "Stored Procedure Fred Failed at Step 5 blah blah blah"

    check the @@ERROR variable right after the statement, and then you can use a GOTO (yeah that's right) to go to an error handling label and then you can return whatever you want with an OUTPUT variable.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  4. #4
    Join Date
    Feb 2008
    Posts
    6
    Thanks million to all, very useful!

    Gian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •