Answers for "Get the Domain Name, Page Name and Query Parameter from a URL"

SQL
0

Get the Domain Name, Page Name and Query Parameter from a URL

DECLARE @URL    VARCHAR(1000)
SET @URL = 'http://www.sql-server-helper.com/tips/tip-of-the-day.aspx?tid=58'

SELECT SUBSTRING(@URL, 8, CHARINDEX('/', @URL, 9) - 8) AS [Domain Name],
       REVERSE(SUBSTRING(REVERSE(@URL), CHARINDEX('?', REVERSE(@URL)) + 1,
       CHARINDEX('/', REVERSE(@URL)) - CHARINDEX('?', REVERSE(@URL)) - 1)) AS [Page Name],
       SUBSTRING(@URL, CHARINDEX('?', @URL) + 1, LEN(@URL)) AS [Query Parameter]
Posted by: Guest on April-30-2021

Code answers related to "Get the Domain Name, Page Name and Query Parameter from a URL"

Code answers related to "SQL"

Browse Popular Code Answers by Language