将分割后的查询结果 更新保存到数据的原来库中
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 systembak.dbo.tianya3
)t
查询语句
systembak 数据名
dbo.tianya3 表
id str name1 emial site em em1 pass mingren 字段列
现在从 str 里面分割成后数据 保存到 name1 emial em pass
如何实现 谢谢大家了
[解决办法]
insert into 你要保存的表(name1 emial em pass)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 systembak.dbo.tianya3 )t
[解决办法]
--try;WITH cte AS(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 systembak.dbo.tianya3)t)UPDATE cte SET name1=name1, emial=emial, em =em,pass=pass
[解决办法]
insert into #test(name1 ,emial, em, pass)--#test要先创建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 systembak.dbo.tianya3 )t