I am learning how to use PATINDEX and REVERSE together. In this case it is a work assignment and any help given will be most appreciated.
I am attempting to pull the state out of a character string. There are two issues: 1) The state abbreviation can start in the last position of the string or five+ positions from the end of the string. 2) when using patindex in the attached TSQL query I am getting the first two characters of the string as opposed to the last two characters.
I am including the first 10 result records and the query itself and have blanked out all data past the state field intentionally as it is not germane to the question and to retain some anonymity to the data.
Once again, I appreciate any help given.