SQLTeam.com | Weblogs | Forums

Substring string from the end till specific character

tsql
sql-server-2014

#1

Hi,

i need to get a string between two characters from the end of the string. E.G:
DECLARE @st varchar(250)
SET @st = 'http://www.somedomain.com/file/rch1231/' the final resoukt should be: rch1231

thanks from advanced,
S


#2
select reverse(replace(substring(reverse(@st),1,charindex('/',reverse(@st),2)),'/',''))

#3

Thanks a lot for the solution. working great.

S