SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Conversion failed
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rjhe22
Constraint Violating Yak Guru

254 Posts

Posted - 08/13/2014 :  06:33:37  Show Profile  Reply with Quote
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

588 Posts

Posted - 08/13/2014 :  07:18:29  Show Profile  Reply with Quote
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

588 Posts

Posted - 08/13/2014 :  07:19:42  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000