locked
Error converting data type nvarchar to numeric. error RRS feed

  • Question

  • User-1506965535 posted

    With my below query 

    select Current_Item_code +'~'+ unit_availabe from WMS_Storage_Bin where 
    status='confirmed'
    and location_area in ('Storage')
    and location_name='A1111'

    I get error as

    Error converting data type nvarchar to numeric.

    Note: unit_availabe is numeric

    Wednesday, November 4, 2015 1:28 AM

Answers

  • User-1716253493 posted
    select Current_Item_code + '~' + CAST(unit_availabe as nvarchar) from WMS_Storage_Bin where 
    status='confirmed'
    and location_area in ('Storage')
    and location_name='A1111'

    if current_item_code is numeric also

    select CAST(Current_Item_code as nvarchar) + '~' + CAST(unit_availabe as nvarchar) from WMS_Storage_Bin where 
    status='confirmed'
    and location_area in ('Storage')
    and location_name='A1111'

    if you want concatenate a number as varchar, convert all number as varchar first

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 4, 2015 1:32 AM