Need Help, RaiseError, Check Constraint or Rules

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slowdance
    New Member
    • Mar 2008
    • 4

    Need Help, RaiseError, Check Constraint or Rules

    Hi! Im new in this forum..

    Obviously I need help,
    Is there a way I can make a Custom Error Message using RaiseError statement?

    This is the problem, I want an error message whenever a user break a rule or a check constraint. I know there's a system error message for that but I want it customize that a user will understand what the error was about. And I just want it in a particular Rule or Check Constraint not all..

    Im just new in SQL so Please help me out.. A sample statement would be nice
    I hope i made sense to you..
  • slowdance
    New Member
    • Mar 2008
    • 4

    #2
    oh Yea, Im using MS SQL 2000 in 2000Advance Server...

    I actually have an idea but i can't put it into syntax..

    My Idea is,,

    I will create a RaiseError Message.. or something like that

    then I will create a StoreProcedure that everytime user violates a check constraint or rule it will trigger/call the RaiseError i made..

    is that possible??!!!

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      use combinations of:

      1. @@error

      2. BEGIN TRY...END TRY BEGIN CATCH...END CATCH

      3.RAISERERROR


      Happy Coding

      -- CK

      Comment

      • slowdance
        New Member
        • Mar 2008
        • 4

        #4
        Originally posted by ck9663
        use combinations of:

        1. @@error

        2. BEGIN TRY...END TRY BEGIN CATCH...END CATCH

        3.RAISERERROR


        Happy Coding

        -- CK
        @@error = 'msg ID' is that the one?

        i never use try and catch before.. would you give me some sample syntax?
        just one...
        does it works in sql2000?

        thanks man, appreciate it

        Comment

        Working...