Need HELP on data cleaning query - simple really, just forgot syntax

  • Hello all -

    Well, I'm stranded here without my books, and I have a brain cramp and cannot access my

    memory.

    Here's the problem -

    I'm loading varchar info into a staging table.

    columns are qtyavail and qtyatbranchavail.  I want to add these and set a 3rd column to that value.  Whilst trying to do this with cast, I discovered a data integrity problem in that some yutz has been entering commas into the qty fields.  Instead of 1024.00, I have 1,024.00 (example).

    I used to have an SQL query that could parse through strings and cleanse this kind of stuff (but it was on another database)  I'd use Substring and Length and I think the other was Index where, on this database, index would return a character position.  So, I could use length to get each row's length for the column, parse through the substring and find the numeric position of the offending character(s) and then take action.

    Does anyone have any ideas on how I could do this?  Thanks.

    randyvol

  • CAST(REPLACE(qtyavail,',','') as numeric(9,2)) + CAST(REPLACE(qtyavail and qtyatbranchavail) as numeric(9,2))

    Far away is close at hand in the images of elsewhere.
    Anon.

  • THANKS !!!!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply