Question

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.

Was it helpful?

Solution

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

OTHER TIPS

You could use

where dsc like 'iPod %' 
or dsc like '% iPod %'
or dsc like '% iPod'

to match where ipod is used as a word, rather than within a word.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top