I have a problem and I hope you can help me.
My problem is that I have to include in an SQL view (that I will later send in visual studio 2013) the fields "city" and "state" but in the source table the data comes in the same column and abbreviated. So I require not only to separate the string, but also to put the state in another column and show the non-abbreviated state, that is, to put "city" in one column and "state" in another.
For example I have in my current table:
CIUDAD
'MONTERREY NL'
'DISTRITO FEDERAL DF'
'SAN NICOLAS GARZA GARCIA NL'
And I need:
CIUDAD|ESTADO
'MONTERREY'|'NUEVO LEON'
'DISTRITO FEDERAL'|'DISTRITO FEDERAL'
'SAN NICOLAS GARZA GARCIA'|'NUEVO LEON'
I already tried with a substring and charindex and nothing. What has caused me more conflict is that the length of the cities and states is variable so I can not extract a certain number of characters and they do not have a delimiter like comma, period or something similar on which I can base to extract and validate the state.