Try it, analyze the result step by step.
declare @string varchar(max) declare @subString varchar(max) set @string = 'this is a duplicated question, but may get some new answers, since tech chagne from time to time as we know'; set @subString = 'this is a duplicated question, but may get some new answers, since tech chagne from time to time' --Find the string.lastIndexof(time) select LEN(@String) select LEN(@SubString) select CHARINDEX('time', REVERSE(@string)) select reverse(@string) select reverse('time') SELECT LEN(@string) - CHARINDEX(reverse('time'), REVERSE(@string)) - Len('time') + 1
ljh Mar 29 '13 at 19:16 2013-03-29 19:16
source share