删除重复记录 [英] Deleting duplicate records

查看:89
本文介绍了删除重复记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了一个SQL查询来查找表中重复记录的数量:
从表名称中

I have tried a sql query to find the number of duplicate records in a table:

select count(*) from table_name a
where rowid >(select min(rowid)
                        from table_name b
                     where a.column1=b.column1
and a.Column2 = b.Column2)



这返回了1203行的结果.
现在,当我尝试运行以下查询以删除这些行时,应用程序挂起并停止响应.



This returned me a result of 1203 rows.
Now when i try to run the below query to delete these rows, the application hangs and stops responding.

delete from table_name a
where rowid >select min(rowid)
                        from table_name b
                     where a.column1=b.column1
and a.column2= b.column2)



还有其他方法吗?请帮助



Is there any other way to do it? Please help

推荐答案

尝试此链接

sql-server-delete-duplicate-records-rows [^ ]
try this Link

sql-server-delete-duplicate-records-rows[^]


看看以下文章
http://support.microsoft.com/kb/139444 [
Have a look at following article
http://support.microsoft.com/kb/139444[^]


1.创建另一个临时或物理表临时使用
2.在该表中插入不同的记录
3.删除现有的具有重复行的行
4.将rown back临时表插入原始表
5.截断/删除临时表

如果数据很大,则使用另一个具有与原始结构相同的物理表....

谢谢
1. Create another table temp or physical for temporary use
2. Insert distinct record in that table
3. Trunace the existing one which has duplicate rows
4. Insert rown back form temp table to original table
5. truncate / delete temp table

If data is large then use another physical table with same structure as of original....

Thanks


这篇关于删除重复记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆