sqlserver删除重复数据
select identity(int,1,1) as autoID, * into #Tmp from [QYTS_QiYeCecdb]
select min(autoID) as autoID into #Tmp2 from #Tmp group by wanfang_id
select * from #Tmp where autoID in(select autoID from #tmp2)
select * into #Tmp3 from (select * from #Tmp where autoID in(select autoID from #tmp2)) as T
select * from #Tmp3
delete [QYTS_QiYeCecdb]
insert into [QYTS_QiYeCecdb] (
[wanfang_id]
,[企业名称]
,[铭牌]
,[简称]
,[曾用名]
,[负责人姓名]
,[负责人]
,[省名]
,[市名]
,[县名]
,[行政区代码]
,[地址]
,[电话]
,[区位号]
,[传真]
,[邮码]
,[电子邮件]
,[网址]
,[成立年代]
,[注册资金]
,[固定资产]
,[职工人数]
,[技术人员数]
,[营业额]
,[利税]
,[创汇额]
,[进出口权]
,[性质与级别]
,[股票代码]
,[机构类型]
,[企业简介]
,[企业占地面积]
,[厂房办公面积]
,[主管单位]
,[派出机构]
,[行业GBM]
,[行业SIC]
,[商标]
,[产品信息]
,[经营项目]
,[经营项目英]
,[产品关键词]
,[英文产品关键词]
,[产品SIC]
,[产品GBM]
,[企业排名]
,[重点行业]
,[成品数据]
,[电力数据]
,[冶金数据]
,[ID]
,[f_id] ) select [wanfang_id]
,[企业名称]
,[铭牌]
,[简称]
,[曾用名]
,[负责人姓名]
,[负责人]
,[省名]
,[市名]
,[县名]
,[行政区代码]
,[地址]
,[电话]
,[区位号]
,[传真]
,[邮码]
,[电子邮件]
,[网址]
,[成立年代]
,[注册资金]
,[固定资产]
,[职工人数]
,[技术人员数]
,[营业额]
,[利税]
,[创汇额]
,[进出口权]
,[性质与级别]
,[股票代码]
,[机构类型]
,[企业简介]
,[企业占地面积]
,[厂房办公面积]
,[主管单位]
,[派出机构]
,[行业GBM]
,[行业SIC]
,[商标]
,[产品信息]
,[经营项目]
,[经营项目英]
,[产品关键词]
,[英文产品关键词]
,[产品SIC]
,[产品GBM]
,[企业排名]
,[重点行业]
,[成品数据]
,[电力数据]
,[冶金数据]
,[ID]
,[f_id] from #Tmp3
drop table #Tmp,#Tmp2