Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Conversion failed

Author  Topic 

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2014-08-13 : 06:33:37
hi
i have the following code
SELECT            Quantity          
FROM dbo.BNYForwardsTaxLotsForwards
WHERE investmentType ='Forward Cash'
and Quantity < 0


and i get the follwoing error
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '-12213949.9' to data type int.

dont understand why i get it. any ideas

Ifor
Aged Yak Warrior

700 Posts

Posted - 2014-08-13 : 07:18:29
You will need to cast the string '-12213949.9' to either a decimal or float first, decide how you want to round it and then cast to an int.
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2014-08-13 : 07:19:42
quote:
Originally posted by Ifor

You will need to cast the string '-12213949.9' to either a decimal or float first, decide how you want to round it and then cast to an int.

An alternative would just be to compare to the float constant 0.0

Go to Top of Page
   

- Advertisement -