How to get only Website Name through query?

 Posted by vishalneeraj-24503 on 7/9/2014 | Category: Sql Server Interview questions | Views: 852 | Points: 40
Answer:

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 Only]

Output:-
dotnetfunda.com


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response