日期:2014-05-17 浏览次数:20551 次
declare @str varchar(100) set @str='0000zt0000 5842001314 0000zt0000@163.com' select name1, email, reverse(substring(reverse(email),1,charindex('@',reverse(email)))) em, replace(replace(@str,name1+' ',''),' '+email,'') pass from ( select substring(@str,0,charindex(' ',@str)) name1, reverse(substring(reverse(@str),0,charindex(' ',reverse(@str)))) email )t
------解决方案--------------------
create table #urTable([str] varchar(1000)) insert into #urTable select '0000zt0000 5842001314 0000zt0000@163.com' select name1, email, reverse(substring(reverse(email),1,charindex('@',reverse(email)))) em, replace(replace([str],name1+' ',''),' '+email,'') pass from ( select substring([str],0,charindex(' ',[str])) name1, reverse(substring(reverse([str]),0,charindex(' ',reverse([str])))) email,[str] from #urTable )t /* name1 email em pass ---------------------------------------------------------------- 0000zt0000 0000zt0000@163.com @163.com 5842001314 (1 行受影响) */
------解决方案--------------------
create table #urTable([str] varchar(1000))
insert into #urTable select '0000zt0000 5842001314 0000zt0000@163.com'
select name1,
email,
reverse(substring(reverse(email),1,charindex('@',reverse(email)))) em,
replace(replace([str],name1+' ',''),' '+email,'') pass from
(
select substring([str],0,charindex(' ',[str])) name1,
reverse(substring(reverse([str]),0,charindex(' ',reverse([str])))) email,[str] from #urTable
)t
------解决方案--------------------
create table #urTable([str] varchar(1000)) insert into #urTable select '0000zt0000 5842001314 0000zt0000@163.com' select name1, email, reverse(substring(reverse(email),1,charindex('@',reverse(email)))) em, replace(replace([str],name1+' ',''),' '+email,'') pass from ( select substring([str],0,charindex(' ',[str])) name1, reverse(substring(reverse([str]),0,charindex(' ',reverse([str])))) email,[str] from #urTable )t
------解决方案--------------------