我有一個loooooong存儲過程,它在數據庫的不同表中運行大約15個select語句 - 我將選擇的所有結果都插入臨時表中。但是 - 該表有一些行是完全重複的。該臨時表看起來是這樣的:從重複的行中選擇一行
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
而且我想如何表看看到底是這樣的:
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
我怎麼能只返回一行,如果有多個重複的行並仍然返回不重複的行?
INT NOT NULL PRIMARY KEY WITH(IGNORE_DUP_KEY = ON)... @ Quassnoi此行將我從錯誤中拯救出來.. – user1947927 2013-01-23 10:27:46