How to replace a part of string in all the column values

  • Hi,

    I have a table with many columns. It contains the details of the products.

    One of the column is product description.

    For example..

    ITEMNMBR DESCRIPTION

    JC463 Tropicana juice " 24 oz

    I want to replace the " with a '+' sign...

    Like that there are 100's of products like that...

    So I need any script which I can run against the table.

    Regards,

    Skybvi

    Regards
    Sushant Kumar
    MCTS,MCP

  • update [table_name] set [column_name] = REPLACE([column_name], '"', '+')

  • I should stress the fact that this will absolutely replace every occurance of the 1st character with 2nd character everywhere it exists in that column. So if that's not exactly what you want to have happen, then don't execute the script. Proper testing should prevail in all cases of data modification and you should backup and restore to a lower environment to test your scenario. At the very least, create a new database in a lower environment and import the data from just this table and test your changes.

  • Richard Moore-400646 (11/28/2011)


    I should stress the fact that this will absolutely replace every occurance of the 1st character with 2nd character everywhere it exists in that column. So if that's not exactly what you want to have happen, then don't execute the script. Proper testing should prevail in all cases of data modification and you should backup and restore to a lower environment to test your scenario. At the very least, create a new database in a lower environment and import the data from just this table and test your changes.

    Wow, great disclaimer! Are you a consultant, by any chance? 😀

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Richard Moore-400646 (11/28/2011)


    I should stress the fact that this will absolutely replace every occurance of the 1st character with 2nd character everywhere it exists in that column. So if that's not exactly what you want to have happen, then don't execute the script. Proper testing should prevail in all cases of data modification and you should backup and restore to a lower environment to test your scenario. At the very least, create a new database in a lower environment and import the data from just this table and test your changes.

    thanks dude,

    Yes, I will be checking this script on some products in a dev environment and make sure the application/software is catching it right as we need it.

    Regards,

    Skybvi

    Regards
    Sushant Kumar
    MCTS,MCP

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

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