Error converting data type numeric to numeric

  • Hi there, I have a headache with this, I am getting this error

    "Error converting data type numeric to numeric"

    I am doing this,

    DECLARE @numero numeric(18,8)

    DECLARE @numero1 varchar(13)

    set @numero1 = '113067.966300'

    select @numero = convert(Numeric(18, 8), ltrim(rtrim(@numero1))) select @numero

    but the called is in a stored procedure, i try to replicated and it works, I put it in another (new) sp and it works, but in the sp that is the one I am working gives me the eror, and the worst is that it makes the changes, in the sp I make some validations is the only different

     if isnumeric(@psExchRate) = 1 

     begin 

       SELECT @pnExchRate = convert(numeric(18,8), @psExchRate)

      if @pnExchRate <= 0

      begin      

       select @sParam = '17'

       goto ErrorHandler

      end     

    can anyone help me please??, I am working with SQL2000, I don´t if I am missing information you need, please let me know.

    Thanks a lot, AnaL

     

  • This was removed by the editor as SPAM

  • Could the full-error message be something like this?

    Server: Msg 8115, Level 16, State 8, Line 8

    Arithmetic overflow error converting numeric to data type numeric.

    If so, it is probably caused by a mismatch in precision or scale between the convert-statement and the variable you're trying to assign to. The following example should reproduce the situation:

    declare @number_str varchar(13), 

            @number     numeric(11, 8)

        set @number_str = '113067.966300'

    select @number = convert(numeric(18,8), @number_str)

    select @number

  • What datatype is this set for:

    @pnExchRate

    It should be declared as NUMERIC(18,8) if it isn't, that's what's causing your problem.

    -SQLBill

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

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