sql刪除重復保留唯一 怎么樣刪除SQLSERVER數(shù)據(jù)庫中重復的數(shù)據(jù)?
怎么樣刪除SQLSERVER數(shù)據(jù)庫中重復的數(shù)據(jù)?——找出重復數(shù)據(jù),通過distinct刪除重復數(shù)據(jù),并將其保存到臨時表selectdistinct*into#aaafrom tablewhereidi
怎么樣刪除SQLSERVER數(shù)據(jù)庫中重復的數(shù)據(jù)?
——找出重復數(shù)據(jù),通過distinct刪除重復數(shù)據(jù),并將其保存到臨時表
selectdistinct*into#aaafrom table
whereidin(selectidfrom table groupbyhaving count(ID)>1)
]--刪除實表中的重復數(shù)據(jù)
delete from table
whereidin(selectidfrom table groupbyhaving count(ID)>1)
--將刪除的重復數(shù)據(jù)插入表以確保表中只有一個重復數(shù)據(jù),并且沒有重復
插入表(列)
從#AAA中選擇列
-如果不需要保留所有重復數(shù)據(jù),請直接將其刪除