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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-09-15 : 10:04:41
|
| I have two tablesTable 1 = Weekly DiariesTable 2 = New DiaryHow do I write a stored procedure to get the duplicates out of both tables?Both tables have the field name HUN where I want to do my search on. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-15 : 10:13:05
|
Duplicates as multiple occurencies in each table?Duplicates as in a match between tables? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-09-15 : 10:13:15
|
| select hun,[dups] = count(*)from Table1group by hunhaving count(*) > 1Jim |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-09-15 : 10:26:56
|
| Thank you both for your reply. I want the matching duplicates to go into another table. How would I add that to this statement?select hun,[dups] = count(*)from Table1group by hunhaving count(*) > 1 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-15 : 10:28:48
|
SELECT t1.Col1, COUNT(*)FROM Table1 AS t1INNER JOIN Table2 AS t2 ON t2.Col1 = t1.Col1GROUP BY t1.Col1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-09-15 : 11:00:52
|
| Thanks! |
 |
|
|
|
|
|