I have a loooooong stored procedure that runs about 15 select statements across different tables in a database - I am inserting all the results of the selects into a temporary table. However - that table has some rows that are exact duplicates. The temporary table looks something like this:
DocID | VisitDate | DocName
8245376 | 8/26/2009 1:07:01 PM | Doc1
8245376 | 8/26/2009 1:07:01 PM | Doc1
8245376 | 8/26/2009 1:07:01 PM | Doc2
8245376 | 8/26/2009 1:07:01 PM | Doc2
646681 | 8/26/2009 1:07:01 PM | Doc3
263272 | 8/26/2009 1:07:01 PM | Doc4
8245376 | 8/26/2009 1:07:01 PM | Doc5
8245376 | 8/26/2009 1:07:01 PM | Doc5
8245376 | 8/26/2009 1:07:01 PM | Doc6
8245376 | 8/26/2009 1:07:01 PM | Doc6
1903875 | 8/26/2009 1:07:01 PM | Doc7
And how I'd like the table to look at the end is like this:
DocID | VisitDate | DocName
8245376 | 8/26/2009 1:07:01 PM | Doc1
8245376 | 8/26/2009 1:07:01 PM | Doc2
646681 | 8/26/2009 1:07:01 PM | Doc3
263272 | 8/26/2009 1:07:01 PM | Doc4
8245376 | 8/26/2009 1:07:01 PM | Doc5
8245376 | 8/26/2009 1:07:01 PM | Doc6
1903875 | 8/26/2009 1:07:01 PM | Doc7
How can I return only ONE row if there are multiple duplicate rows and still return rows that are not duplicates?