Please start any new threads on our new site at http://forums.sqlteam.com. 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
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to check for duplicate row data
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

567 Posts

Posted - 01/24/2013 :  10:02:38  Show Profile  Reply with Quote
How to check duplicate rows based on these columns: 259k rows are in teh table.
Is it possible to see a count based on teh combination of all fields, to se how many rows are there.

select table_name, active, businessunitid, cost_center, glacct, glsubacct from LAW_DEL_IMGNOW_GLACCT_CHG;


Thank you very much for the helpful info.

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 01/24/2013 :  11:11:31  Show Profile  Reply with Quote
You can use the row_number function or group by clause - in the example below, I am using group by. If you want to see only rows that have duplicates, uncomment the last line
select 
table_name, active, businessunitid, cost_center, glacct, glsubacct, COUNT(*) AS DupCount 
from LAW_DEL_IMGNOW_GLACCT_CHG
GROUP BY 
select table_name, active, businessunitid, cost_center, glacct, glsubacct from LAW_DEL_IMGNOW_GLACCT_CHG
-- HAVING COUNT(*) > 1
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 01/25/2013 :  01:35:50  Show Profile  Reply with Quote
quote:
Originally posted by James K

You can use the row_number function or group by clause - in the example below, I am using group by. If you want to see only rows that have duplicates, uncomment the last line
select 
table_name, active, businessunitid, cost_center, glacct, glsubacct, COUNT(*) AS DupCount 
from LAW_DEL_IMGNOW_GLACCT_CHG
GROUP BY 
select table_name, active, businessunitid, cost_center, glacct, glsubacct from LAW_DEL_IMGNOW_GLACCT_CHG
-- HAVING COUNT(*) > 1



fixed typos

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 01/25/2013 :  07:59:51  Show Profile  Reply with Quote
How embarrassing! Thank you Visakh.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 01/25/2013 :  09:45:14  Show Profile  Reply with Quote
No problem..

It happens to all

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.04 seconds. Powered By: Snitz Forums 2000