DECLARE @Text VARCHAR(100) = '123 The Street Bracknell Berkshire RG12 1AA'SELECT REPLACE(REVERSE(LEFT(REPLACE(REVERSE(@Text),' ', '.'), CHARINDEX('.', REPLACE(REVERSE(@Text),' ', '.'), CHARINDEX('.', REPLACE(REVERSE(@Text),' ', '.'), 0)+1)-1)), '.', ' ')
I replaced an empty space to . and then a . to an empty space. You can eliminate that step and look for an empty space directly to make it a little faster.Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.