Search code examples
sqlsql-serverreplacesql-server-2000string-formatting

Replacing specific part of a sting


I have a large table with IT products (nearly 3 million records) in there I could see rocords like..

1 Port Euro Wall Charger + Uk Adapter 5v 2.1a For IPod / iPhone / iPad - White - Ip-653

In here as you can see 'IPod' is not in standard format (iPod). So I came up with this SQL and implemented following.

update tablename
set dsc = replace(dsc, 'iPod', 'iPod')
where dsc not like'%iPod%' collate sql_latin1_general_cp1_cs_as
and dsc like '%iPod%'

After applying this to all records, it has done the formatting which I want but it has done some unwanted changes too, like...

100in **TriPod** Canvas CarryinGBag For T100uwv1 Screen 

is there a way to overcome this kind of changes, can I use RegEx. Please advice.


Solution

  • Adding space before and after ipod in like clause will probably solve your problem.