I'm dealing with the nasty subject of Addresses in SQL. For the most part my data is good.
For the problem records I have a field in SQL called "FULLADDRESS" which I need to split into "Unit", "PrefixLetter", "HouseNumber", "SuffixLetter", "StreetName"
example FULLADDRESS:
FULLADDRESS
345A MIDAVALO WAY
R73 MIDAVALO WAY
10/22 MIDAVALO WAY
3/R85C MIDAVALO WAY
where
3
= UNIT
R
= PREFIXLETTER
85
= HOUSENUMBER
C
= SUFFIXLETTER
There also may be some with numbers following the road - these are part of the road name e.g.
FULLADDRESS
R3050 HIGHWAY 29
What is a way I can separate the different house number parts in a query? Am i going to be able to do this SQL or do I need to export into Excel and manipulate there (this is not preferred but can be done if it's the only option).
The addresses always have the same structure, however not all of them have all components.
I've started with
SELECT
substring(FULLADDRESS, 0, charindex('/', FULLADDRESS, 0)) as UNIT
FROM
ADDRESS
but I'm now unsure how to continue to pull out all parts of the address particularly where I need some after the /
and some where there is no /
etc.