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 2000 Forums
 Transact-SQL (2000)
 Delete repeated rows of selected columns

Author  Topic 

erni
Starting Member

2 Posts

Posted - 2003-12-17 : 22:11:22
I've done as follows:

SELECT col1, col2, col3, col4, COUNT(*) REPEATS FROM TABLE1
GROUP BY col1, col2, col3, col4
HAVING COUNT(*) > 1

and got the results for repeated rows of those selected columns.
Now, how do I go about deleting the entire row of these records from the table?

SamC
White Water Yakist

3467 Posts

Posted - 2003-12-17 : 22:32:58
quote:
how do I go about deleting the entire row of these records from the table?


There's no way to delete a partial row. Sounds like you need to delete "all" the rows when there are more than 1. But I think you want to delete the duplicates and leave 1 row?

Read this article.
Go to Top of Page

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2003-12-18 : 04:41:04
[CODE]
SELECT DISTINCT col1, col2, col3, col4 INTO TABLE1_NO_DUPS
FROM TABLE1
[/CODE]

?

________________
Make love not war!
Go to Top of Page

erni
Starting Member

2 Posts

Posted - 2003-12-23 : 01:13:22
Thank you for directing to the article Amy, and also thanks Sam.

Select DISTINCT is my prefered solution in my case.
Go to Top of Page
   

- Advertisement -