Link to home
Start Free TrialLog in
Avatar of Gowtham Ramamoorthy
Gowtham Ramamoorthy

asked on

Conversion failed when converting the varchar value '115,89' to data type int.

Hi,

How to resolve the above error for the below code description  ?

Begin

Declare @InputUnit AS Varchar(256)
Set @InputUnit = (Select Query which returns the value 115,89)
SELECT ................. left join.....
      
WHERE
Dimension_ID = 8155 AND Geography_ID = 3346 AND DVid =2 AND Collection_ID=5 ANDUnit_ID1 IN (@Inputcount)

END
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>@InputUnit AS Varchar(256)
>(Select Query which returns the value 115,89)
So you're trying to assign a numeric value '118,89' to the varchar @InputUnit.
The data types have to be the same, so you'll have to CAST the '118,89' as a varchar, i.e.

Declare @InputUnit AS Varchar(256)
Set @InputUnit = (Select CAST('115,89' as varchar(256)))

Open in new window


Also, tell us if 'the value' has a column data type of varchar, numeric, or int.
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia 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
Is there a typo in your question?
You're declaring @InputUnit variable and then using @Inputcount in your SELECT statement.