PDA

View Full Version : populate numeric col with data from varchar


lilith
05-31-02, 17:35
I need to populate (UPDATE) a field called 'analy' with the numeric data from a varchar field called 'result'. The problem is there are alpha characters in some of the values. I need to weed those out and set only the numeric values into 'analy'. I keep getting the 'Error converting data type varchar to numeric.' error in query analyzer. I've tried a bunch of different things and have tried to minimize it to just an update statement setting analy=result where isnumeric(result) =1. Can anyone help me out?

I'm using sql server 2000 if it matters.
Thanks in advance!
L

rnealejr
05-31-02, 23:40
Is result part of the same table as analy ? What is the key field for this table ? Do you want to update analy with the field result from the same row ?

lilith
06-03-02, 14:22
rnealejr,
Thanks for your reply.
1. 'result' is in the same table as 'analy'.

2. pKey is the primary key generated on creation/update of table (this table is created from a dtc pulling data from a view that lives on another server and administered by someone that sits very far away from me...don't know how they have databases without keys, but they do so I added my own).

3.I do want to update analy with the field result from the same row.
Thanks again.
WJ