create table tUrlLoaction(chrUrl varchar(100))insert tUrlLoaction select 'publishers.clickbooth.com'
insert tUrlLoaction select 'aaaa.good.beechwoodsgroup.net'
insert tUrlLoaction select 'sinna.googbb.ccceke.locssb.ni.cn'
insert tUrlLoaction select 'peat.com'
insert tUrlLoaction select '66.51.168.186'
insert tUrlLoaction select 'operatic.org'
--select * from tUrlLoaction
gocreate function f(@s varchar(100))
returns varchar(100)
as
begin
declare @result varchar(100)
while charindex('.',right(@s,len(@s)-charindex('.',@s)))>0
begin
set @s=right(@s,len(@s)-charindex('.',@s))
end set @result=@s
return @result
end
goselect chrUrl,dbo.f(chrUrl) from tUrlLoactiondrop function f
drop table tUrlLoaction
insert tUrlLoaction select 'aaaa.good.beechwoodsgroup.net'
insert tUrlLoaction select 'sinna.googbb.ccceke.locssb.ni.cn'
insert tUrlLoaction select 'peat.com'
insert tUrlLoaction select '66.51.168.186'
insert tUrlLoaction select 'operatic.org'
--select * from tUrlLoaction
gocreate function f(@s varchar(100))
returns varchar(100)
as
begin
declare @result varchar(100)
while charindex('.',right(@s,len(@s)-charindex('.',@s)))>0
begin
set @s=right(@s,len(@s)-charindex('.',@s))
end set @result=@s
return @result
end
goselect chrUrl,dbo.f(chrUrl) from tUrlLoactiondrop function f
drop table tUrlLoaction
走之前最后一帖~~~
--------------------------
那么早?我都还得加班!
charindex('.',reverse('publishers.clickbooth.com'),1+charindex('.',reverse('publishers.clickbooth.com')))-1)
declare @a table(chrurl varchar(100))
insert into @a select 'publishers.clickbooth.com' union all select
'aaaa.good.beechwoodsgroup.net' union all select
'sinna.googbb.ccceke.locssb.ni.cn' union all select
'peat.com' union all select
'66.51.168.186' union all select
'operatic.org'select reverse(substring(REVERSE(chrurl),1,
(case when charindex('.',REVERSE(chrurl),charindex('.',REVERSE(chrurl))+1)=0 then len(chrurl) else charindex('.',REVERSE(chrurl),charindex('.',REVERSE(chrurl))+1)-1
end))) from @a
特别是 YiZhiNet ,算法严谨!好!
做Asp.net开发,和更改国外一些代码。
希望和大家做个朋友,互相进步!