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
Comments
Post a Comment