Based on the sample data, the assumption is the address format always the same. I would suggest to use
PATHINDEX
+ expression +
RIGHT
+
REVERSE
functions to manipulate the string. See below example. To find the city name, use the substring from position 0 to position of the state abbreviation.
To find the state position, assume that the state will always start with a space, then two characters, follow by a space and then follow by a number. etc...
DECLARE @table1 TABLE (
Address1 VARCHAR(50)
)
INSERT INTO @table1
SELECT 'Florida fl 40005' UNION
SELECT 'los angeles al 50066' UNION
SELECT ' EL Paso TX 79901'
SELECT
City = SUBSTRING(Address1, 0, PATINDEX('%[ ][a-z][a-z][ ][1-9]%',Address1)),
[State] = SUBSTRING(Address1, PATINDEX('%[ ][a-z][a-z][ ][1-9]%',Address1), 3),
Zip = RIGHT(Address1, CHARINDEX(' ', REVERSE(Address1)) - 1) FROM @table1
Output:
City State Zip
EL Paso TX 79901
Florida fl 40005
los angeles al 50066