I have data shown below. I'd like to extract the last part after the last underscore. The data before the underscore can be any length but written with the same syntax i means : letters_letters_letters. So i wrote this code to extract the part after the last underscore then it's works perfectly but i noticed that there is 2 names written differently like (letters_letters-letters ) with - instead of _ at the end.
NAME= (SELECT SUBSTRING('''+@NAME+''', CHARINDEX(''_'','''+@NAME+''',CHARINDEX(''_'','''+@NAME+''')+1)+1, CHARINDEX(''_'','''+@NAME+''') + CHARINDEX(''_'','''+@NAME+''',CHARINDEX(''_'','''+@NAME+''')+1)) FROM TABLE)
My question is : is there away to check or extract string after any character (without specify if it's underscore or other) ?
Can anyone help please.
Column name is like :
BOB_LOU_K
the thow others columns are like :
BOB_LOU-K
Thanks