Link to home
Start Free TrialLog in
Avatar of Curtis Long
Curtis LongFlag 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??
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Curtis Long

ASKER

How do you define the data type during import??  I do not see that option in the wizard
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.

User generated image