I have address information parsed into several columns and I'm trying to concatenate the columns into one with no leading or trailing spaces using a view. I have tried LTRIM and RTRIM but can't seem to figure out how to get rid of leading/trailing spaces.
I am using SQL Server 2008 R2. Below is a sample of how our data is stored. The Address column is the output I'm looking/hoping to get.
Thanks in advance!
HouseNo|PreDir|StName|SufType|SufDir|UnitType|UnitNo|City |State|Zip |Address|
123 | |Main |St | | | |Anytown |CA |55555|123 Main St Anytown, CA 55555
245 | |3rd |Ave |NE | | |Anytown |CA |55555|245 3rd Ave NE Anytown, CA 55555
4675 |W |Elm |Dr | | | |Anytown |CA |55555|4675 W Elm Dr Anytown, CA 55555
789 |E |1st |St | |Apt |5 |Anytown |CA |55555|789 E 1st St Apt 5 Anytown, CA 55555
432 | |Locust|Blvd |SE | | |Anytown |CA |55555|432 Locust Blvd SE Anytown, CA 55555