Professional Web Applications Themes

Overriding a default error message in SQL Server - Microsoft SQL / MS SQL Server

Dear sir, Just to rephrase my question in relation to the previous posting. Is it possible to override a default error message? For example, I type convert 'Select (datetime, '56/04/2004', 103)'. When I run this, it will give me an error saying 'Arithmetic overflow'. Instead of SQL server printing the message out, is it possible that i override it with my own message? Or even make my query 'ignore it'? The worst thing would be to hack the sysmessage and change the message (haven't tried and I don't want to). Thanks! Regards, Anson...

  1. #1

    Default Overriding a default error message in SQL Server

    Dear sir,

    Just to rephrase my question in relation to the previous posting.

    Is it possible to override a default error message? For example, I
    type convert 'Select (datetime, '56/04/2004', 103)'. When I run this,
    it will give me an error saying 'Arithmetic overflow'. Instead of SQL
    server printing the message out, is it possible that i override it
    with my own message? Or even make my query 'ignore it'? The worst
    thing would be to hack the sysmessage and change the message (haven't
    tried and I don't want to).



    Thanks!

    Regards,

    Anson
    anson Guest

  2. #2

    Default Re: Overriding a default error message in SQL Server

    Don't hack sysmessages.

    If you execute convert 'Select (datetime, '56/04/2004', 103)' you'll get
    syntax error!

    Try this:

    declare err int
    Select convert(datetime, '56/04/2004', 103)
    set err = error
    if err <> 0
    begin
    if err = 242
    begin
    raiserror ('Error converting datetime to string! Error %u!', 16, 1, err)
    end
    end

    This way you get to error messages! One from SQL server and one custom, from
    your code. If you want
    to now which one is which in ADO error collection then and a tag that would
    help you.

    For example:

    if err = 242
    begin
    raiserror ('<CustomErr>Error converting datetime to string! Error %u!',
    16, 1, err)
    end


    --
    Dean Savovic
    [url]www.teched.hr[/url]


    "anson" <aeze616cse.unsw.edu.au> wrote in message
    news:cb7ba330.0306292312.41c3b19cposting.google.c om...
    > Dear sir,
    >
    > Just to rephrase my question in relation to the previous posting.
    >
    > Is it possible to override a default error message? For example, I
    > type convert 'Select (datetime, '56/04/2004', 103)'. When I run this,
    > it will give me an error saying 'Arithmetic overflow'. Instead of SQL
    > server printing the message out, is it possible that i override it
    > with my own message? Or even make my query 'ignore it'? The worst
    > thing would be to hack the sysmessage and change the message (haven't
    > tried and I don't want to).
    >
    >
    >
    > Thanks!
    >
    > Regards,
    >
    > Anson

    Dean Savovic Guest

Similar Threads

  1. OBDC server error message
    By dodo1979 in forum Coldfusion Database Access
    Replies: 0
    Last Post: November 27th, 03:51 PM
  2. Server error message
    By mlwebmac in forum Macromedia Contribute Connection Administrtion
    Replies: 0
    Last Post: October 12th, 01:04 PM
  3. Server unavailable - error message
    By iannetdata in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: April 13th, 04:03 PM
  4. JDBC and MS SQL server error message
    By Steve Grosz in forum Macromedia ColdFusion
    Replies: 3
    Last Post: March 10th, 01:29 AM
  5. #25341 [NEW]: P error if using server variables as default function argument value
    By martin at lucas-smith dot co dot uk in forum PHP Development
    Replies: 0
    Last Post: September 1st, 11:56 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139