Unexpected Replace results

Posted on 2011-04-25
Last Modified: 2012-05-11
Using the following UPDATE statement, I do not get the results I expect.
Update WSWebProductName set ProductNameTextHtml = Replace(ProductNameTextHtml,'%'+Char(153)+'%','™') where IDNo = 382

Open in new window

In the field ProductNametextHTML there are trademarks which I can find using the where clause:
Where ProductNameTextHtml like '%' + Char(153) + '%'

I am trying to replace the Char(153) with the HTML text ™. When I run the query in Visual Basic or in SSMS, I am notifield one record is updated. But when I view the record in SSMS the TM is still there and not the ™. When I run the query again, I get feed back that one record was affected.
The Field ProductNametextHTML is a varchar(50) field.

Why is the REPLACE not working? What is the correct way to accomplish the replacement?
Question by:mpdillon
    LVL 33

    Accepted Solution

    as long as IDno=382 uniquely identifies the row, you don't need the % symbols - just do this:

     Replace(ProductNameTextHtml, Char(153) ,'™')

    Author Closing Comment

    Thanks. That was it.
    I was using 382 as an example but there are hunreds of there records that need replacing.

    LVL 33

    Expert Comment

    I'm not sure why I thought it was necessary to identify specific rows.  The update will work just fine for the whole table.  :)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now