日期:2014-05-17  浏览次数:20551 次

SQL2005 对字段进行拆分
这样才可以把 
某一个字段 字符拆分成 多个字段如
准备拆分的



拆分后的




希望有人回答 谢谢了 真心谢谢

------解决方案--------------------
SQL code

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

------解决方案--------------------
探讨
谢谢你的回答 真心感谢
请允许我追问一个问题
如果是 很多这样的勒

------解决方案--------------------
SQL code
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


------解决方案--------------------
SQL code

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

------解决方案--------------------
探讨

引用:
SQL code

create table #urTable([str] varchar(1000))
insert into #urTable select '0000zt0000 5842001314 0000zt0000@163.com'

select name1,
email,
reverse(substring(reverse(email……