Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mike13
Posting Yak Master
219 Posts |
Posted - 2014-05-15 : 11:51:37
|
Hi all,I got city and zipcode switch on big amount of customer records (programmer made error inserting records).i want to correct it, but how can dowhere zipcode like (if it has numbers in it)do not think there is any city in the world that has numbers in the name ;-)thanks a lot |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-05-15 : 11:59:34
|
Is the city all numbers? if so, then you can try a WHERE clause like:WHERE col1 NOT LIKE '%[^0-9]%' |
|
|
mike13
Posting Yak Master
219 Posts |
Posted - 2014-05-15 : 12:35:21
|
no sorry forgot some zipcode have letters.Here is sample of some whole batch that are wrong.Maybe it is easier if if just chars including country specific (ex: glyngøre)zipcode, city, countryglyngøre 7870 DENMARKSão Paulo 2264070 BRAZILhull hu95ty UNITED KINGDOMcarrizal 1201 VENEZUELAforest hill 76140 UNITED STATEScarolina 982 PUERTO RICOMonroe 97456 UNITED STATESglasgow g349fb UNITED KINGDOMTimisoara 300510 ROMANIAleeds ls133rg UNITED KINGDOMbrighton East sussex bn25fj UNITED KINGDOMNiagara Falls On L2E 3T1 CANADAMakawao 96768 UNITED STATESlondon nw10 8sa UNITED KINGDOMSofia 1000 BULGARIAdunedin 9012 NEW ZEALANDoakland 94606 UNITED STATESbramming 6740 DENMARKstevenson ranch 91381 UNITED STATES |
|
|
mike13
Posting Yak Master
219 Posts |
Posted - 2014-05-19 : 05:58:38
|
I figured it out(zipcode LIKE '%[a-z]%'OR zipcode LIKE '%[A-Z]%') aNd not( zipcode like '%[0-9]%') |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-05-19 : 19:09:22
|
If no City has a digit in its name...[CODE]update MyTableset City = Zipcode, Zipcode = Citywhere City like '%[0-9]%'[/CODE]Also, I'm wondering if you're getting yourself in trouble with Unicode characters, like in "São Paulo" which may lie outside the [a-z] spectrum. Opportunity is missed by most people because it is dressed in overalls and looks like work. - T.A.Edison |
|
|
|
|
|