tsql - extract string using SUBSTRING

Viewed 7998

I have a column where I need to extract the remainder of a string starting from "_". Example below:

TF_Bskt Trade would need to be "Bskt Trade"
SSC_Equity would need to be "Equity"
etc ......

So I've got this far using the TF_Bskt Trade example:

SELECT SUBSTRING ('TF_Bskt Trade' ,CHARINDEX('_','TF_Bskt Trade')+1, length)

However i'm getting myself confused with how to make sure the length is from the start of after the _ and the end of the string so that it is dynamic? Basically so it caters for varying degrees of string length from after "_".

Any ideas of how to efficiently achieve this?

1 Answers
Related