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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 UK POSTCODE

Author  Topic 

deanglen
Yak Posting Veteran

65 Posts

Posted - 2012-09-24 : 08:29:42
Hi

We have a SQL table where the majority of our Post code/zip code are in the United Kingdom. Is there a way to not only change these to upper case (where they are lower) but also somehow format them so that they match the UK postal code method (XXXX XXX or XX XXX etc).

I would imagine it would be selecting all records where Country = UK and then using an Upper command? That is the first step but if anybody knows how to validate the poscode that would be great. I have looked on the forum and Google but they seem to be related to specific CMS, rather than just SQL.

Thanks!

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-24 : 08:37:09
As you indicated, converting to upper case is simple - just use the UPPER function. Validating is much harder and may not even be possible to 100 percent accuracy. Take a look at this thread to see if that will help you at all: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=154282

Also, this article by Peso may be useful: http://weblogs.sqlteam.com/peterl/archive/2008/08/13/Validate-UK-postcode.aspx
Go to Top of Page
   

- Advertisement -