Update....

  • Hello

    I have a field name called description, and i will like to update all rows with the word 'Jasper Conran' to 'JC'.

    eg 'Black and Green Jasper Conran XXL' to 'Black and Green JC XXL'

    'Black and Red Jasper Conran XXL' to 'Black and Red JC XXL'

    does anyone have an idea how this can be done with a query to update the whole table with a million rows?

  • If I read this correctly and you ONLY want to change the values of Jasper Conran to JC then you can use the REPLACE command...

    SET , 'Jasper Conran', 'JC' )

    DAB

  • Sorry about that, the " "got stripped.

    I meant

    SET column1 = REPLACE( column1, 'Jasper Conran', 'JC' )

  • SQLServerLifer (10/28/2008)


    Sorry about that, the " "got stripped.

    I meant

    SET column1 = REPLACE( column1, 'Jasper Conran', 'JC' )

    I'd go a little further:

    update dbo.YourTable set

    description = replace(description, 'Jasper Conran', 'JC')

    where

    description like '%Jasper Conran%';

  • Lookup REPLACE in Books Online:

    SELECT REPLACE(description, 'Jasper Conran', 'JC') ...

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 5 posts - 1 through 4 (of 4 total)

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