get the domain name 2c page name and query parameter from a url

Solutions on MaxInterview for get the domain name 2c page name and query parameter from a url by the best coders in the world

showing results for - "get the domain name 2c page name and query parameter from a url"
Matteo
31 Sep 2019
1DECLARE @URL    VARCHAR(1000)
2SET @URL = 'http://www.sql-server-helper.com/tips/tip-of-the-day.aspx?tid=58'
3
4SELECT SUBSTRING(@URL, 8, CHARINDEX('/', @URL, 9) - 8) AS [Domain Name],
5       REVERSE(SUBSTRING(REVERSE(@URL), CHARINDEX('?', REVERSE(@URL)) + 1,
6       CHARINDEX('/', REVERSE(@URL)) - CHARINDEX('?', REVERSE(@URL)) - 1)) AS [Page Name],
7       SUBSTRING(@URL, CHARINDEX('?', @URL) + 1, LEN(@URL)) AS [Query Parameter]
8
similar questions