Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to find duplicated rows in a table


how to find duplicated rows in a table

Author
Message
marcelo miorelli
marcelo miorelli
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 396
Comments posted to this topic are about the item how to find duplicated rows in a table
adnan.korkmaz
adnan.korkmaz
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 165
edit: this should be one of the most basic queries ever. so, i have been surprised why you have choosen to add an identity column and querying the table twice with joins, etc.

shouldn't the script below suit your needs?

select y,x
from t1 (NOLOCK)
group by y, x
having count(1) > 1
iskarta
iskarta
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 15
Infact, I didin't understand why you wrote like that code.
Where is the difference from below code.

I think It's very easy.

SELECT * FROM t1 WHERE y IN (
SELECT y FROM t1
GROUP BY y
HAVING COUNT(y)>1
)

Thanks.
ABHILASH DHONGDI
ABHILASH DHONGDI
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 102
this has gotta be the most pathetic script i've ever seen...

I'm surprised SSC even published this!!
Maysarah
Maysarah
SSC-Addicted
SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)

Group: General Forum Members
Points: 479 Visits: 145
WHY???

you can use the following
SELECT
x,
y,
COUNT(y) AS How_Many_Times
FROM t1
GROUP BY x, y
HAVING (COUNT(y) > 1)


I don't understand 1.why do you have to add a rowid!! 2.what is the purpose of adding a third column (z) with a default value of zero!!!
Sam-263310
Sam-263310
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 97
ABHILASH DHONGDI (6/18/2008)
this has gotta be the most pathetic script i've ever seen...

I'm surprised SSC even published this!!


My thoughts, exactly. You can pick any line in the article and find problems with it. Awful.
Yorgs Neil
Yorgs Neil
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 170
I would have to agree with the other posts...
this script stinks on ice.

How does this warrant a hyperlink to the "solution script".

Lets keep the quality of the site high....
Fortunately, it usually is


Sick
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search