Home Forums SQL Server 2008 T-SQL (SS2K8) Can I Proper case a UK address string with postcode with a function RE: Can I Proper case a UK address string with postcode with a function

  • sgmunson - Thursday, July 12, 2018 6:24 AM

    Well, if you at least have spaces between each element, you could use a string splitter (see Jeff Moden's article here:  http://www.sqlservercentral.com/articles/72993/ ) to get to each element, then as long as an element is not either of the last 2 elements, you UPPER() the leftmost character, and LOWER() the remainder.  Otherwise, the last 2 elements are treated to UPPER() in their entirety.   Then you reassemble the address using STUFF and FOR XML PATH('') and a space for the separator.

    Hi Steve

    Thanks for the post I had thought of having to do that but just wanted to know if anyone had found another way

    Kind regards
    Stig of the dump