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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Converting a column's datatype

Author  Topic 

Paul Kendall
Starting Member

4 Posts

Posted - 2004-10-08 : 13:33:37
Hello,

I just posted this in the 'General' forum, but this forum might be more appropriate.

I'm new to SQL, so please bear with me. I have a table in which I need to perform arithmetic operations but cannot because the datatype is varchar instead of numeric. So, instead, I have added a new column to the table, of the numeric datatype, and I am trying to dump everything from the original varchar column into the numeric column, but I have to convert the data as I do this.

Thus, I am trying to work along the lines of:

update tablexyz
set columnB (the numeric one) = columnA(the varchar one)

but I'm sure I would have to use a case statement and convert() function. Can anyone give me any tips on how to do this, please?

Any help much appreciated!!!

-Paul

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-08 : 15:13:55
update tablexyz
set columnB = convert(decimal(12,8), columnA)

look up CAST and Convert in BOL = Books On-Line = SQL Help

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -