Getting only Website Name through Query

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 809
Suppose,we have following URL as:-
http://www.dotnetfunda.com/interviews/postexamquestion.aspx?, and we have to extract dotnetfunda.com from above URL,then write below query to get only website name
declare @Url as nvarchar(1000) = 'http://www.dotnetfunda.com/interviews/postexamquestion.aspx?';
Select substring(replace(@Url,'http://www.',''),0,charindex('/',replace(@Url,'http://www.',''))) as [Website Name]

Output:-
dotnetfunda.com

Comments or Responses

Login to post response