I'm trying to return a substring of the following, it's comma delimited [only one comma]
City-City-City, State-State-State
Sometimes it's only one city and state, sometimes it's more than one of either [or both]
Basically, I need to just return the state initials pass the comma. What's the best way to do this? I'm looking into the substring function, but that doesn't seem that smart. I found a split function but it looks like overkill and I don't like to use code I don't understand.
Ex:
Cincinnati-Middletown, OH-KY-IN
Cleveland-Elyria-Mentor, OH
Abilene, TX
Output:
OH-KY-IN
OH
TX
Thanks for the answers;I just figured it out thanks to Sonam's starting point. Here's what I got. Haven't looked into it but it seems to returning the right stuff.
select substring(CBSAName,charindex(',',CBSAName)+1, LEN(CBSAName)) FROM CBSAMasterList