Find Replace

  • I would like to find all the items that have 'BALLOONS PTA SAVVY 2 X 10 120CM'   'BALLOONS PTA SAVVY 2 X 10 110CM'               in my description field and change to              'BALLOON PTA  SAVVY 2 X 10 120CM'.    'BALLOON PTA SAVVY 2 X 10 110CM' 

    IF I use find like %balloons% and replace with balloon won't it get rid of the rest of the descriptiin?

     

    THANKS

  • What you do is search on the wildcard string and replace the literal string...thus...

    SET QUOTED_IDENTIFIER OFF

     update TABLE set COLUMN_A =REPLACE(COLUMN_A,"BALLOONS","BALLOON")

       where COLUMN_A like "%BALLOONS%"

     

    Run it in a transaction and check the results before committing as always.



    Shamless self promotion - read my blog http://sirsql.net

  • I get the following when I run
     update ITEM set DESCR=REPLACE(DESCR,BALLOONS,"BALLOON")

       where COLUMN_A like "%BALLOONS%"

    Server: Msg 207, Level 16, State 3, Line 1

    Invalid column name 'BALLOONS'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'BALLOON'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'COLUMN_A'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name '%BALLOON%'.

    The descr is in one col

    BALLONS PTA SAVVY 2 X 10 120CM'  

    THANKS AGAIN

  • You're missing the quotes around the first BALLOONS, and need to change the second column name from COLUMN_A, also make sure to set the quoted identifier off..should be

     

    SET QUOTED_IDENTIFIER OFF

    update ITEM set DESCR=REPLACE(DESCR,"BALLOONS","BALLOON")

       where DESCR like "%BALLOONS%"



    Shamless self promotion - read my blog http://sirsql.net

  • SO SO SO SWEAT,

    THANKS CAIN

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

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