sql server - SQL query to extract extension from middle of URL -


how write single sql query extracting file extension urls if have url :

1) www.xyz.com\hello\world\filea.txt?id=01 2) www.xyz.com\hello\world\filea.txt 

please if knows it

if using ms t-sql:

1) select substring (url, charindex('?', url) - 3, 3)

2) select right(url, 3)

so combine them follows:

select case when charindex('?', url) <> 0 substring (url, charindex('?', url) - 3, 3)        else right(url, 3)        end extension 

charindex

patindex


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -