| Author |
Topic |
|
offspring22
Starting Member
38 Posts |
Posted - 2009-09-29 : 16:36:27
|
| So I have a field called "address" which I need to break down into direction, street type, name, etc. I have been able to pull out the street dir and type, and remove them from the address field, but with street name I'm having some trouble as some have 1 word, some have 2. Ie, 123 happy dale , and 456 Smile. I can pull out the far right word, but that leaves me with half of the street name. Anyway I can pull out all the alpha characters, or failing that pull out everything after the first set of numbers, and a seperate query to remove them after the fact and leave me with just the house number?IE, a select where "123 happy dale" becomes "happy dale" and "456 smile" becomes just "smile" etc? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
offspring22
Starting Member
38 Posts |
Posted - 2009-09-30 : 12:03:29
|
| Sure, I've already parsed out street direction, and type as mentioned. I don't need the address field left in tact after the fact, so I can put say the number and put it into its proper field, then take out the number from the address field leaving it only the street name, if that's easiest. Here's a sample of what I have.108 Heritage Lake108 Heritage Lake108 John108 Marischal108 Millarville108 Niblock108 Stuart108 Sunrise108 Sunset108 Wooldridge Park109 AberdeenAnd I'd need to break it out into108108108108108108108108108108109and Heritage LakeHeritage LakeJohnMarischalMillarvilleNiblockStuartSunriseSunsetWooldridge ParkAberdeen |
 |
|
|
offspring22
Starting Member
38 Posts |
Posted - 2009-09-30 : 12:16:53
|
| There is the occasional street type that is a number as well, as well as numbers longer, or shorter than 3 digits...ie:4 Ridge Pointe42 Sunrise432 Pine Creek432 Pine Creekwhich would change into442432432and Ridge PointeSunrisePine CreekPine Creek |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-01 : 02:16:21
|
quote: Originally posted by offspring22 There is the occasional street type that is a number as well, as well as numbers longer, or shorter than 3 digits...ie:4 Ridge Pointe42 Sunrise432 Pine Creek432 Pine Creekwhich would change into442432432and Ridge PointeSunrisePine CreekPine Creek
SELECT RTRIM(LEFT(Address,CASE WHEN PATINDEX('[A-Z]%',Address) > 0 THEN PATINDEX('[A-Z]%',Address)-1 ELSE LEN(Address) END)) AS StreetType,SUBSTRING(Address,CASE WHEN PATINDEX('[A-Z]%',Address) > 0 THEN PATINDEX('[A-Z]%',Address) ELSE NULL END,LEN(Address)) AS typeFROM Table |
 |
|
|
briceeric
Starting Member
3 Posts |
Posted - 2011-03-26 : 18:44:02
|
| For anyone looking to parse address delivery lines in SQL Server, you may want to consider Ambient Concepts SqlAddress which provides a set of SQLCLR functions for making this easy: unspammed |
 |
|
|
|