SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

533 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

3555 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
52309 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

3555 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
52309 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000