日期:2014-05-17 浏览次数:20855 次
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (URL nvarchar(56),目标 nvarchar(20))
insert into [TB]
select 'http://news.17173.com/','17173' union all
select 'http://mail.airland.com/','airland' union all
select 'http://wenku.baidu.com/','baidu' union all
select 'http://www.surveyhead.com/','surveyhead' union all
select 'http://photo.weibo.com/','weibo' union all
select 'http://webmail.mail.163.com/','163' union all
select 'http://photo.renren.com/','renren' union all
select 'https://my.alipay.com/','alipay' union all
select 'http://s96.917st.com/','917st' union all
select 'http://bbs.egou.com/','egou' union all
select 'http://9yinbbs.woniu.com/','woniu' union all
select 'http://mail.qq.com/','qq' union all
select 'http://quan.51fanli.com/','51fanli' union all
select 'http://quote.eastmoney.com/','easymoney'
select * from [TB]
SELECT url,REVERSE(SUBSTRING(REVERSE(REPLACE(url,'.com/','')),0,PATINDEX('%.%',REVERSE(REPLACE(url,'.com/','')))))
FROM TB
/*
url (无列名)
http://news.17173.com/ 17173
http://mail.airland.com/ airland
http://wenku.baidu.com/ baidu
http://www.surveyhead.com/ surveyhead
http://photo.weibo.com/ weibo
http://webmail.mail.163.com/ 163
http://photo.renren.com/ renren
https://my.alipay.com/ alipay
http://s96.917st.com/ 917st
http://bbs.egou.com/ egou
http://9yinbbs.woniu.com/ woniu
http://mail.qq.com/ qq
http://quan.51fanli.com/ 51fanli
http://quote.eastmoney.com/ eastmoney*/
select url,目标=parsename(url,2) from tb