第一步:將表中的數據放到一個臨時表裏面
Select Identity(Int, 1, 1) As id,
* Into #temp
From DianPingPoi dpp
Where dpp.DistrictId = 4313 And dpp.CuisineId = 210
第二步:刪除臨時表裏面的重複數據
Delete #temp
Where id Not In (Select Max(id)
From #temp
Group By
所有該表的列名)
第三步:刪除表裏面符合條件的數據
Delete from DianPingPoi Where DistrictId=4313 And CuisineId=116
第四步:將臨時表裏面的數據插入到表中
Insert Into DianPingPoi
(
所有該表的列名
)
Select 所有該表的列名 From #temp
第五步:刪除臨時表
Drop table #temp
刪除SQL表中重複的數據
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章