首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

将分割后的查询结果 更新保存到数据的原来库中,该如何解决

2012-09-27 
将分割后的查询结果 更新保存到数据的原来库中select name1,email,reverse(substring(reverse(email),1,ch

将分割后的查询结果 更新保存到数据的原来库中
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

如何实现 谢谢大家了

[解决办法]

SQL code
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
[解决办法]
SQL code
--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
[解决办法]
探讨

引用:
SQL code
insert into 你要保存的表(name1 emial em pass)
select name1,
email,
reverse(substring(reverse(email),1,charindex('@',reverse(email)))) em,
replace(replace([str],name1+' ',''),' '……

[解决办法]
探讨

引用:
SQL code

--try
;WITH cte AS
(
select name1,
email,
reverse(substring(reverse(email),1,charindex('@',reverse(email)))) em,
replace(replace([str],name1+' ',''),' '+email,'') pass……

[解决办法]
步骤一:
SQL code
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 

热点排行