Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data conversion

Status
Not open for further replies.

junkmail

Programmer
Jan 7, 2001
134
US
Can someone tell me how to convert a varchar to a real number? everything I tried gives me the same error that you can't convert a varchar to real.
 
What have you tried so far?
How about:
Code:
SELECT CAST('123.45'AS REAL )
SELECT CONVERT(REAL, '123.45' )
 
I already tried both and get the same error can't convert varchar to real.
 
That worked for me..
Check your data, you most likely have bad data somewhere
 
Try running a query like this...

Code:
Select YourColumn
From   YourTable
Where  IsNumeric(YourColumn) = 0

There are certain things in string data that will return true by the IsNumeric function, but would still error when converting to real. However, I suspect that the query shown above will likely show you the bad data you have in the table.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top