Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update columns from Varchar to Decimal

Author  Topic 

Bjcascone
Starting Member

37 Posts

Posted - 2009-06-08 : 09:33:57
I am trying to update the column type of a table from Varchar(75) to Decimal Using the command:

Alter Table [DB].dbo[tablename]
Alter Column [columnName]
Decimal (4)

There is currently no data in the fields i am updating they are all going to be blank untill i insert new data in them.

I am getting the error "Error Converting data type varchar to numeric"

Is there a better way to do this?

Thank you for your help!
Brian

raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-08 : 09:47:36
When there is no data in that column then just drop that varchar column and recreate the same column with decimal datatype and do as u like further...
Go to Top of Page

Bjcascone
Starting Member

37 Posts

Posted - 2009-06-08 : 10:03:04
How would i drop a select few columns and then recreate them?
Go to Top of Page

Bjcascone
Starting Member

37 Posts

Posted - 2009-06-08 : 10:13:45
I figured it out! it was operator error!! Thank you for your help.
Go to Top of Page
   

- Advertisement -