选出重复行,注意<或者>可以留下最大值或者最小值,<>删除全部重复值

整理数据库select *  from newbindtable as b1 
整理数据库
where b1.serviceuserName in(select serviceusername from newbindtable 
整理数据库
where serviceusername=b1.serviceusername and bindid<b1.bindid)
整理数据库

删除重复行

整理数据库delete newbindtable from newbindtable as b1
整理数据库
where b1.serviceuserName in(select serviceusername from newbindtable 
整理数据库
where serviceusername=b1.serviceusername and bindid<b1.bindid)
整理数据库

删除完全重复行

整理数据库select distinct * into #temp from newsipidtable
整理数据库
drop table newsipidtable
整理数据库
select * into newsipidtable from #temp
整理数据库
drop table #temp


用内连接选出数据

整理数据库select b.serviceusername,b.password,substring(b.serviceusername,0,charindex('@',b.serviceusername)) as passport, s.sipid,s.sippwd from newbindtable as b
整理数据库
inner join newsipidtable as s
整理数据库
on b.serviceusername=s.jid
整理数据库

把选出的数据存到表中:

整理数据库select * into new5
整理数据库
from 
整理数据库(
select b.serviceusername,b.password,substring(b.serviceusername,0,charindex('@',b.serviceusername)) as passport, s.sipid,s.sippwd from newbindtable as b
整理数据库
inner join newsipidtable as s
整理数据库
on b.serviceusername=s.jid) as f
整理数据库

用正则:
1、把选择好的数据拷贝到UtraEdit
2、在替换中写正则如:^(.*)\t(.*)\t(.*)\t(.*)\t(.*)$,不同与.net中的语法
3、被替换文本:

整理数据库insert into bind(passport,password,email,question,answer,bindvalue)values('\1','\2','','','','<?xml version="1.0"?>  <ServiceInfos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">    <ServieInfo>      <ServiceName>Sip</ServiceName>      <Username>\4</Username>      <Password>\5</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>VirtualBank</ServiceName>      <Username>\3</Username>      <Password>\2</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>Blog</ServiceName>      <Username>\3</Username>      <Password>\2</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>Ex</ServiceName>      <Username>\5</Username>      <Password>\2</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>Jabber</ServiceName>      <Username>\1</Username>      <Password>\2</Password>    </ServieInfo>  </ServiceInfos>')
整理数据库

4、生成的sql语句

整理数据库insert into bind(passport,password,email,question,answer,bindvalue)values('0@im.chinabubble.com','muxu323','','','','<?xml version="1.0"?>  <ServiceInfos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">    <ServieInfo>      <ServiceName>Sip</ServiceName>      <Username>1000000080</Username>      <Password>267153</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>VirtualBank</ServiceName>      <Username>0</Username>      <Password>muxu323</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>Blog</ServiceName>      <Username>0</Username>      <Password>muxu323</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>Ex</ServiceName>      <Username>267153</Username>      <Password>muxu323</Password>    </ServieInfo>    <ServieInfo>      <ServiceName>Jabber</ServiceName>      <Username>0@im.chinabubble.com</Username>      <Password>muxu323</Password>    </ServieInfo>  </ServiceInfos>')
整理数据库

相关文章:

  • 2022-01-16
  • 2021-11-23
  • 2022-01-02
  • 2021-08-10
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-03-27
  • 2021-11-17
  • 2021-11-18
  • 2021-05-24
  • 2021-12-01
  • 2021-04-23
相关资源
相似解决方案