DECLARE @S VARCHAR(200) SET @S = 'Pic/2009/1/200913051280669_S.jpg' SELECT REVERSE(SUBSTRING(REVERSE(@S),1,CHARINDEX('/',REVERSE(@S))-1))
declare @s varchar(400) set @s='Pic/2009/1/200913051280669_S.jpg' set @s=REVERSE(left(REVERSE(@s),charindex('/',REVERSE(@s))-1)) print @s
declare @a table(url varchar(1000)) insert @a select 'Pic/2009/1/200913051280669_S.jpg' union all select 'Pic/2009/11/200913051280669_S.jpg' union all select 'Pic/2009/2/200913051280669_S.jpg'update @a set url=stuff(url,1,charindex('/',url,10),'')select * from @a /* url ----------------------------------------------- 200913051280669_S.jpg 200913051280669_S.jpg 200913051280669_S.jpg */
SET @S = 'Pic/2009/1/200913051280669_S.jpg'
SELECT REVERSE(SUBSTRING(REVERSE(@S),1,CHARINDEX('/',REVERSE(@S))-1))
declare @s varchar(400)
set @s='Pic/2009/1/200913051280669_S.jpg'
set @s=REVERSE(left(REVERSE(@s),charindex('/',REVERSE(@s))-1))
print @s
insert @a
select 'Pic/2009/1/200913051280669_S.jpg' union all
select 'Pic/2009/11/200913051280669_S.jpg' union all
select 'Pic/2009/2/200913051280669_S.jpg'update @a
set url=stuff(url,1,charindex('/',url,10),'')select * from @a
/*
url
-----------------------------------------------
200913051280669_S.jpg
200913051280669_S.jpg
200913051280669_S.jpg
*/