查询重复数据已经可以了
select 字段1,字段2,count(*) from Product group by 字段1,字段2 having count(*) > 1删除重复数据出现问题,等待求解.delete from 表 a where 字段1,字段2 in(select 字段1,字段2,count(*) from 表 group by 字段1,字段2 having count(*) > 1)提示错误如下服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: 'a' 附近有语法错误。希望高人指点一二.谢谢
select 字段1,字段2,count(*) from Product group by 字段1,字段2 having count(*) > 1删除重复数据出现问题,等待求解.delete from 表 a where 字段1,字段2 in(select 字段1,字段2,count(*) from 表 group by 字段1,字段2 having count(*) > 1)提示错误如下服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: 'a' 附近有语法错误。希望高人指点一二.谢谢
as
(select * ,row=row_number()over(partition by 字段1,字段2 order by 字段1) from 表a
)
delete c where row>1
---SQL2005以上版本
where exists( select 1 from 表A a where 字段1=a.字段2 and 字段2=a.字段2 and id<>a.id)
(select check(字段1,字段2) from 表 group by 字段1,字段2 having count(*) > 1)
如:ID列在表中唯一的
create table ta(ID int identity primary key,Name nvarchar(10))\
go
insert ta select 'A'
insert ta select 'A'
where exists( select 1 from 表A a where 字段1=a.字段2 and 字段2=a.字段2 and 1_ID<>a.1_ID)
delete a from Product a
where exists( select 1 from Product a where Title=a.User and User=a.User and 1_ID<>1_ID)(所影响的行数为 0 行)
没有删除重复的阿
处理表重复记录(查询和删除)
http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html