0

Here is my string 'ABCDEF-24-04-07-001' and all i want is to get last string separated by -(hyphen) i.e. 001.

But another complexity for me that, the above string may vary i.e. it may be 'ABC-24-07-01' OR 'ABCDE-24-07-010' OR 'ABCDE-24-07-1'.

Please help me to get solution for the above problem

1
  • What you have tried so far? Commented Jul 24, 2015 at 12:15

1 Answer 1

1

Here is the code

DECLARE @string VARCHAR(32) = 'ABCDE-24-07-010';
select REVERSE(SUBSTRING(REVERSE(@string),0,CHARINDEX('-',REVERSE(@string))))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.