I need to be able to output a string which will return everthing up a specified character, I believe making use of charindex is the best way to approach this but I am unsure of the syntax required.
Some examples:
- If a string is equal to
"601-Test-Test2_Test3"then I wish to return601 - If a string is equal to
"42-Test_test3"then I wish to return42 - If a string is equal to
"1-Test_test3"then I wish to return1