DECLARE @full_path VARCHAR(1000)
SET @full_path = '\\SERVER\D$\EXPORTFILES\EXPORT001.csv'
SELECT SUBSTRING( @full_path , LEN(@full_path) - CHARINDEX('\',REVERSE(@full_path)) + 2 , LEN(@full_path) )
Result :
EXPORT001.csv
Syntax
select url,
(CASE WHEN CHARINDEX('/', url, 1)=0 THEN url ELSE RIGHT(url, CHARINDEX('/', REVERSE(url)) - 1) END) AS ResultValue
from(
select 'Articles/Search/ArtMID/2681/ArticleID/2218/Diet.aspx' as url union
select 'OurStory/MD.aspx' as url union
select 'AMD.aspx' as url
)dummytablename
Result value :
SET @full_path = '\\SERVER\D$\EXPORTFILES\EXPORT001.csv'
SELECT SUBSTRING( @full_path , LEN(@full_path) - CHARINDEX('\',REVERSE(@full_path)) + 2 , LEN(@full_path) )
Result :
EXPORT001.csv
Syntax
select url,
(CASE WHEN CHARINDEX('/', url, 1)=0 THEN url ELSE RIGHT(url, CHARINDEX('/', REVERSE(url)) - 1) END) AS ResultValue
from(
select 'Articles/Search/ArtMID/2681/ArticleID/2218/Diet.aspx' as url union
select 'OurStory/MD.aspx' as url union
select 'AMD.aspx' as url
)dummytablename
Result value :
No comments:
Post a Comment