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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Find duplicate rows

Author  Topic 

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2015-10-22 : 15:37:09

How can I find duplicate rows based on 2 columns ?

If data is below
col1 col2 col3 col4 col5 ...
val1 val2 val3 val4
val1 val2 val5 val6
val1 val3 val7 val8
val0 val3 val7 val8

Result based on col1 and col2 is

col1 col2 col3 col4 col5 ...
val1 val2 val3 val4
val1 val2 val5 val6

vedjha
Posting Yak Master

228 Posts

Posted - 2016-06-18 : 12:07:06
select count(col1),col1 rom tablename group by col1 having count(col1) >1

http://kiransoftech.com
Go to Top of Page
   

- Advertisement -