Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Find duplicate rows
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

283 Posts

Posted - 10/22/2015 :  15:37:09  Show Profile  Reply with Quote

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

Posting Yak Master

228 Posts

Posted - 06/18/2016 :  12:07:06  Show Profile  Visit vedjha's Homepage  Reply with Quote
select count(col1),col1 rom tablename group by col1 having count(col1) >1
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000