• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Unexpected Replace results

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?
thanks,
pat
0
mpdillon
Asked:
mpdillon
  • 2
1 Solution
 
knightEknightCommented:
as long as IDno=382 uniquely identifies the row, you don't need the % symbols - just do this:

 Replace(ProductNameTextHtml, Char(153) ,'™')
0
 
mpdillonAuthor Commented:
knightEknight,
Thanks. That was it.
I was using 382 as an example but there are hunreds of there records that need replacing.

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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now