sql 截取 host 函数

USE [UILogDB]
GO
/****** Object:  UserDefinedFunction [dbo].[Sub_UrlHost]    Script Date: 11/09/2011 09:25:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<jianxiong>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
ALTER FUNCTION [dbo].[Sub_UrlHost] (@Url varchar(300))

RETURNS varchar(300)
AS
BEGIN
	
	if (CHARINDEX('/',@Url,8)=0)
		return @Url
	
	return (replace(replace(SUBSTRING(@Url,1,CHARINDEX('/',@Url,8)),'http://',''),'/',''))
		
END


你可能感兴趣的:(host)