Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
nicky_river
Yak Posting Veteran
55 Posts |
Posted - 2010-10-18 : 08:28:35
|
| How do i only find duplicate records in a table, which is given below.A B1 abc1 def1 ggg2 serg3 awer |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-18 : 08:41:18
|
| By record i understand all the selected columns.In the data posted by you I don't see any duplicate records.To start with:Select <columns >From <your table>Group by <Columns selected in select statement>Having count(*) >1 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-18 : 09:29:15
|
select * from tablewhere id in (select id from table group by id having count(*) > 1) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
shaggy
Posting Yak Master
248 Posts |
Posted - 2010-10-18 : 11:26:27
|
| declare @t table (col1 int)insert @t select 1union allselect 1union allselect 2union allselect 3union allselect 4union allselect 5union allselect 5union allselect 6union allselect 7union allselect 8select col1 from (select ROW_NUMBER() over (partition by col1 order by col1) rno,* from @t )awhere rno > 1 |
 |
|
|
|
|
|