|
data base unlimited data base unlimited |
||||||||||
|
||||||||||
|
Home Up Autonumbering SQL Problems Correlation Temp tables Denormalisation Semi-dynamic SQL7 SP2
|
PostcodesPostcodesSQL rule for correct UK Post CodesYou may need to correct UK Postal Codes at T-SQL level. The following has been developed from the full Royal Mail post code rules book: select left(corrected,datalength(corrected)-3) +
' ' + right(corrected,3) when nospaces like '[a-z][a-z][o0-9][o0-9][a-z][a-z]'
then when nospaces like '[a-z][a-z][o0-9][a-z][o0-9][a-z][a-z]'
then when nospaces like '[a-z][o0-9][o0-9][a-z][a-z]'
then when nospaces like '[a-z][a-z][a-z^o][o0-9][a-z][a-z]'
then when nospaces like '[a-z][1-9][o0-9][o0-9][a-z][a-z]'
then when nospaces like '[a-z][a-z][1-9][o0-9][o0-9][a-z][a-z]'
then else as corrected from (select ltrim(rtrim(UPPER(REPLACE(convert(varchar(8),[postcode]),' ','')))) nospaces from memberaddresses) part1 ) part2
Copyright DBU 2000.
|
Location Map
Updates
|
||||||||