Shaz Shaz - 15 days ago 6
SQL Question

Removing a specific set of data from a link

I have the following link:

/ABCDEF/ABCDEF/ABC/8921/154535


I need to insert only the last 6 numbers i.e.
154535
in a column in a table.

Answer

Try below code:

Declare @s varchar(100) = '/ABCDEF/ABCDEF/ABC/8921/154535'
select REVERSE(SUBSTRING(REVERSE(@s),0,CHARINDEX('/',REVERSE(@s))))
Comments