Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 reverse substr extract 2 digits or chars from righ

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-12-27 : 17:44:48
Can you please provide reverse sub string capturing from right 2 charecters/digits:

it can be 5 digit or 6 digit data, want to capture the right side 2 digits.

example: 72509
123110

after extract: it should be: 09 , 10

Thank you very much for the helpful info.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-12-27 : 18:05:36
You can just grab the last 2
SELECT RIGHT(digits,2) or if digits is a number
SELECT RIGHT(convert(varchar(6),digits),2)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -