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