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.
| Author |
Topic |
|
bluefish
Starting Member
1 Post |
Posted - 2003-01-11 : 06:13:31
|
| Hello!I want to select all rows accept the ones that are DISTINCT. Im looking for duplicate strings that exist more than once in the same column.Like this:ID fldString1 string12 string23 string34 string4 <---5 string4 <---6 string57 string6So, its easy to select the DISTINCT values, but how about all accept the DISTINCT values. In this case string4 should be returned, and also if there are any other duplicates.Thanks for any help!/Marcus |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-01-11 : 12:28:00
|
| This problem appears easy at first:SELECT fldStringFROM MyTableGROUP BY fldStringHAVING Count(*) > 1The *next problem* is how to delete JUST ONE of the duplicates.There is a short article on how to do exactly this on sqlteam's home page, search for "duplicate" in the Article Search.The article is titled "Deleting Duplicate Records".HTHSam |
 |
|
|
simondeutsch
Aged Yak Warrior
547 Posts |
Posted - 2003-01-13 : 22:26:40
|
| Check out this link:http://sqlteam.com/Forums/topic.asp?TOPIC_ID=21164Emanaton made this procedure. It has several params, as you can see for yourself, which are very handy (and make this proc one which you like to keep for later use), one of which lets you specify whether to delete the dups or not.I'm running SQL 7, and when I ran this proc, I got several syntax errors, but the sp did run, and do its work. Since it worked, I never bothered to debug it. Maybe it's using some stuff that doesn't work in SQL 7 (like table vars), I should really check. I'm just telling you this so you shouldn't think the sp isn't working.Sarah Berger MCSD |
 |
|
|
|
|
|
|
|