June 23, 2011 at 8:16 am
I need to convert a column (Result) from text to float in a big table (about 150000 records). For example, the original data was stored in Result is mixed text and number, such as "1.33", "50", ">60", "not available"... I need to keep in Result is number like "1.33", "50"... How to code to finish this job?
June 23, 2011 at 8:22 am
here is how i would do it:
1.add a new float column to the table.
2.UPDATE table set newcolumn = convert(float,oldcolumn) where isnumeric(oldcolumn) =1
3. the columns that were non-numeric willb e null.....do you want to default them to zero, or leave null...
4. drop the old column
5. rename the new column
Lowell
June 23, 2011 at 8:58 am
Thank you, Lowell.
It works great!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply