Click here to Skip to main content
15,921,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using the following query to convert the data type of a column from nvarchar to numeric.
SQL
alter table emp.dbo.grimage alter column nags numeric

but when I run the command i got the following error :-

Error converting data type nvarchar to numeric.
The statement has been terminated.
Posted
v2
Comments
Do you have data in your table ? Or is it blank ?
Patel Shailendra 9-Dec-12 0:02am    
ALTER TABLE tableName
ALTER COLUMN Column_Name numeic (in your case)

1 solution

The problem is when you try to alter the table column, the DataBase Engine try to convert all the data present in that column to the new datatype.

So, unless the data present in that table against that column is numeric, it will throw exception that "Error converting...".

So, you have to
1. delete all the data present in that column (for the rows which don't have data of numeric datatype), then
2. alter the column and
3. insert data again with numeric values.

Thanks...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900