删除单个表中的重复项 [英] Removing Duplicates in a single table
本文介绍了删除单个表中的重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下表和数据如下:
I have the following table and data as follows:
sno name city
1 simbu bangalore
1 simbu bangalore
1 simbu bangalore
1 simbu bangalore
1 simbu bangalore
1 simbu bangalore
现在我必须删除重复项。我怎么能做到这一点?事情是我没有包括任何主键。没有主键概念我必须删除重复我怎么能做tat?在删除重复项后,最后应保留6行中的1行。现在可以告诉我如何使用排名函数执行上述操作?
now i have to remove the duplicates . how can i accomplish this? the thing is i have not included any primary key. without primary key concept i have to remove duplicates how can i do tat? out of those 6 rows 1 row should remain finally after removing the duplicates. Now can any 1 tell me how can i perform the above operation using ranking functions?
推荐答案
[ ^ ]
你可以检查一下......它会对你有帮助..
Remove Duplicate Rows from a Table in SQL Server[^]
You can check this...it will help you..
你可以试试这样的事情,假设你的数据在一个名为 mytable的表中;
You could try something like this, assuming your data is in a table called mytable;
select distinct * into #mytemptable from mytable
truncate table mytable
insert into mytable select * from #mytemptable
drop table #mytemptable
希望这个帮助,
Fredrik
Hope this helps,
Fredrik
参考这些链接
从SQL Server中的表中删除重复行 [ ^ ]
如何从SQL Server中的表中删除重复的行 [ ^ ]
SQL SERVER - D elete Duplicate Records - Rows [ ^ ]
删除SQL表中的重复行 [ ^ ]
问候..:)
Refer these links
Remove Duplicate Rows from a Table in SQL Server[^]
How to remove duplicate rows from a table in SQL Server[^]
SQL SERVER – Delete Duplicate Records – Rows[^]
Delete Duplicate Rows in a SQL Table[^]
Regards..:)
这篇关于删除单个表中的重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文