Mohi Mohi - 3 months ago 8
SQL Question

SQl server - How Update with string replace

How can I update some of fields

UPDATE Product
SET Title = REPLACE(Title , 'mn%', 'za%')
WHERE (Title LIKE N'mn%')


Consider data of one field is 'mnfmnd' and must changing to 'zafmnd'

Answer

I would be inclined to use stuff() for this purpose:

update product
    set title = stuff(title, 1, 2, 'za')
    where title like 'mn%';
Comments