Avatar of Curtis Long
Curtis Long
Flag for United States of America asked on

convert sql column from nvarchar to numeric

I have a SQL database called BBKTrial, a table called dbo.sheet1$. a column called [as-am].  This column is nvarchar(225) format.  I need to convert it to numeric.

How can I do this??
Microsoft SQL ServerMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
Vitor Montalvão

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
PortletPaul

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
PortletPaul

You can protect against conversion errors using iSNUMERIC() but this completely safe.

e.g.

select CONVERT( [as-am] as decimal(12,3) )
from that_table
where ISNUMERIC([as-am]) = 1

a result of 1 from ISNUMERIC() indicates the parameters holds numeric information but this can include items such as currency symbols

We could advise better if you supplied this:

select distinct [as-am]
from that_table
where ISNUMERIC([as-am]) = 0
SOLUTION
Jim Horn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Dung Dinh

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Vitor Montalvão

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Curtis Long

ASKER
How do you define the data type during import??  I do not see that option in the wizard
Vitor Montalvão

In the Import Wizard when you chose the worksheets and the destination table, click on "Edit Mappings..." button and will pop-up a new screen where you can change column names and data types.

EditMappings.PNG
Your help has saved me hundreds of hours of internet surfing.
fblack61