Link to home
Start Free TrialLog in
Avatar of W.E.B
W.E.B

asked on

SQL 2008 Conversion failed

Hello,
can you please help, (Im usning SQL 2008 R2)
Error
Conversion failed when converting the varchar value 'KM' to data type int.
Conversion failed when converting the varchar value 'sh' to data type int.

Select xxxxxx,
Case
       When PickupPostalCode LIKE 'J0W%' THEN 'km'
       When DeliveryPostalCode LIKE 'J0W%' THEN 'km'
       When DeliveryZoneId = 2175 THEN 01
       When ScheduledOrderNo > 0 THEN 'sh'
       ELSE DeliveryZoneId END AS [DeliveryZoneId]
From xxxxxxxxxxxxxx

Your help is appreciated.
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Try this..

Select xxxxxx,
Case 
       When PickupPostalCode LIKE 'J0W%' THEN 'km'
       When DeliveryPostalCode LIKE 'J0W%' THEN 'km'
       When DeliveryZoneId = 2175 THEN '01'
       When ScheduledOrderNo > 0 THEN 'sh'
       ELSE CAST(DeliveryZoneId AS VARCHAR(100)) END AS [DeliveryZoneId]
From xxxxxxxxxxxxxx

Open in new window

Avatar of W.E.B
W.E.B

ASKER

Hi Pawan
Same error
Conversion failed when converting the varchar value ....
Can you please post the entire query ?
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of W.E.B

ASKER

Thank you very Much.
worked.
Great !...Welcome...
Avatar of W.E.B

ASKER

Thank you