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

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