Error converting data type nvarchar to float

select
*,  BILL_FACTOR*convert (float, AWP_PRICE)
from dbo.Awpmed

[BILL_FACTOR] [float] NULL ,
[AWP_PRICE] [nvarchar] (255)  NULL ,

Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to float.

How to do?
JohnLucaniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nito8300Commented:
First perform a group by on AWP_PRICE to make sure all values can be converted to float.
0
nito8300Commented:
or you can try getting rid of records like ' '

select *,  BILL_FACTOR*convert (float, LTRIM(RTRIM(AWP_PRICE)))
from dbo.Awpmed

Hope this helps.
0
JohnLucaniaAuthor Commented:
Why do we need 'group by' here??
I need to run the calculation for each.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JohnLucaniaAuthor Commented:
still gave me:


Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to float.
0
nito8300Commented:
The idea is to browse thru the values and see if any are invalid to convert to float.

run this statement and see if you see invalid values
select AWP_PRICE
from dbo.Awpmed
group by AWP_PRICE
ORDER by AWP_PRICE

and the again

select AWP_PRICE
from dbo.Awpmed
group by AWP_PRICE
ORDER by AWP_PRICE DESC
0
Aneesh RetnakaranDatabase AdministratorCommented:
I think there may be values having more than one decimal point
run this

select * from Awpmed where AWP_PRICE like '%.%.%'
0
nmcdermaidCommented:
A quick way to find your non-numeric values

select *
from dbo.Awpmed
where ISNUMERIC(AWP_PRICE) = 0

This will list all your non numeric figures which will need to be cleaned up before they can be converted to a numeric type.
0
imran_fastCommented:
try this
======
select *,  BILL_FACTOR*convert (float, replace(AWP_PRICE,' ',''))
from dbo.Awpmed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.