substring and charindex

Experts! I need to get a substring from right to left intil the first charindex '\'. Example:
'\\cdw22\personal3$\JMARTINEZ3', will look like this: 'JMARTINEZ3'. LEN of characters are not fixed. Thanks!
marshaklanaAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this will do:
select reverse(  left(    reverse(yourfield) , charindex('\', reverse(yourfield))-1)) from yourtable

Open in new window

0
 
czlongCommented:
What if we want to get "personal3$", how would that be done?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.