September 9, 2015 at 3:16 am
BWFC (9/8/2015)
A correctly formed postcode can be 7 or 8 characters - eg SW1A 4WW so change RIGHT(PostalCode, 7) to RIGHT(PostalCode, 8) and LTRIM the result
Postcodes can be 6,7 or 8 characters, M1 2DF is also a valid format.
That's a new one on me - cheers for that.
I'm a DBA.
I'm not paid to solve problems. I'm paid to prevent them.
September 9, 2015 at 3:23 am
andrew gothard (9/9/2015)
BWFC (9/8/2015)
A correctly formed postcode can be 7 or 8 characters - eg SW1A 4WW so change RIGHT(PostalCode, 7) to RIGHT(PostalCode, 8) and LTRIM the result
Postcodes can be 6,7 or 8 characters, M1 2DF is also a valid format.
That's a new one on me - cheers for that.
You're welcome. It's mainly big cities that are single letters. Manchester's M, Birmingham's B, Liverpool's L and Glasgow's G. N,E and W are parts of London with 6 character postcodes too.
How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537
September 9, 2015 at 7:34 am
A UK postcode is always formed of two parts
The first part and will be of the form 1 or 2 letters indicating the posttown followed by 1 or 2 numbers this is followed by a single space then 1 number and two letters.
Note some areas of London use a non standard variant where the second letter of the first part can be a number eg. SW1E 2AA and also Girobank in Bootle also has a non standard format GIR 0AA - this is historic because that postcode was created before the formatting standard was laid down.
There are a few other exceptions e.g. SAN TA - I don't think you will be surprised as to what that is intended for.
September 9, 2015 at 9:23 am
Hi All,
Thank you for the additional information. I am still trying find a fix regarding what has been variable length of the postcode string. I would welcome any further suggestions.
Thanks in advance
September 9, 2015 at 9:41 am
Assume whoever input the postcode does not understand where the space should be - you probably wont be far off.
Strip out all spaces then take last 3 chars, prepend with space, prepend with the rest (2-4 chars).
September 10, 2015 at 12:17 am
Hi All,
After taking into consideration (e.g. variants & possible typos) it will be very difficult to provide a future proof solution. It looks like the best approach will be to cleanse the table or use an alternative view as a lookup.
Many thanks for your suggestions and advice.
Kind regards
September 11, 2015 at 5:39 am
We have postcodes in our database which only have the first "half", I expect that is not uncommon - i.e. the user was able to figure out / was given the town-bit only. That is still (so I believe?) useful to post Office / Postie so I think worth preserving if you have it.
Thus it might be worth also trying to handle "Northants NN4"
September 14, 2015 at 9:12 am
Dealing with partial postcodes greatly complicates things
Is B91 really B91 or is it supposed to be B9 1
B91 is Solihull and B9 is Saltley about 10 miles apart and much further in terms of affluence.
Errors arising from miscoding these may greatly change the results of the analysis. As a consequence you may wish to exclude any incomplete entries in some cases.
September 14, 2015 at 9:42 am
crmitchell (9/14/2015)
Dealing with partial postcodes greatly complicates things.
Indeed ... ultimately its should be down to whatever the Client wants ...
"Is B91 really B91 or is it supposed to be B9 1. B91 is Solihull and B9 is Saltley about 10 miles apart and much further in terms of affluence."
The "9" might have got there from a badly written "A" incorrectly transcribed ... Postie's got quite a bit further to go in that case!
September 14, 2015 at 9:51 am
Just a short walk from Bradford lol.
I suppose it could also be a badly written S - i.e. Bristol - shouldn't take them more than a few minutes. ๐
September 14, 2015 at 10:06 am
๐ Your point about Affluence is important though. I tend to think in terms of "getting goods delivered" but no doubt our clients are also reporting using geo-coding for other purposes.
Viewing 11 posts - 16 through 25 (of 25 total)
You must be logged in to reply to this topic. Login to reply