troubleshooting Question

data conversion problem

Avatar of cipriano555
cipriano555 asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
4 Comments1 Solution322 ViewsLast Modified:
I'm trying to convert an nvarchar that holds a formatted numerical value into a FLOAT.

For example, we have  a table...

CREATE TABLE [dbo].[aadata_test](
      [testval] [nvarchar](50) NULL
) ON [PRIMARY]

it contains this value:


SELECT [testval]
  FROM [IntegratedMedicalBillingDataWarehouse].[dbo].[aadata_test]


testval
--------------------------------------------------
$1,000,000.00

(1 row(s) affected)

I want to convert it to a number, so I try this:

SELECT cast([testval] as float)
  FROM [IntegratedMedicalBillingDataWarehouse].[dbo].[aadata_test]

But get this error message.

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


How do you do this kind of conversion to get a numerical value?

Thanks,

C
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros