RAISERROR failed due to invalid parameter substitution(s)

  • I am getting the above error and have no idea what it is. Has anybody seen it before? Any ideas how it can be fixed?

    Msg 2757, Level 16, State 1

    Regards


    Kindest Regards,

    JCrock

  • Somewhere in your code you are using the RAISERROR command and you are not supplying the correct parameters to the error string. 

    RAISERROR ('The level for job_id:%d should be between %d and %d.',

          16, 1, @@JOB_ID, @@MIN_LVL, @@MAX_LVL)

    In the above example, the parameters @@JOB_ID, @@MIN_LVL, @@MAXLVL will be inserted into the error string 'The level...' in place of the parameter placeholders %d, %d and %d respectively.

    To get your error, you have omited a parameter, or are using the incorrect format (e.g. string instead of int).

    You can also use predefined messages that are stored in sysmessages.  If you are doing so, 'SELECT from sysmessages WHERE error = msg_id' where Msg_id is the number you are using in your RAISERROR as follows:

    RAISERROR(msg_id, 16, 1, parameters)

    Check that you are passing the correct parameters to the msg_id, and that they are on the correct format:

    %d or %i = signed integer

    %o = unsigned octal

    %p = pointer

    %s = string

    %u = unsigned integer

    %x or %X = unsigned hexadecimal

     

     


    When in doubt - test, test, test!

    Wayne

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

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