Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL - parsing UK postcode info

$
0
0

Hi guys,

I'm trying to create a function that looks at a postcode, then checks it against a field and returns an ID from another table. The problem I'm having is that the field it needs to look up against contains a list of possible postcodes with wildcards. A good example would be:

Text
N1-99, N1?, NW1?, NW*, BR* 

In this instance, ? represents any alpha character, * represents any character, and #-## represents all numbers between and including # & ## (so, N1 - N99).

I've gotten as far as stripping out the first part of a postcode from a string, but I don't really know the best angle to come at this from. I'd guess the first thing I need to do is break up the lookup list and check each entry individually against the postcode, but I'm at a bit of a loss as to where I should go from there.

I've attached a list of IDs and their associated...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>