developers world

tecnical questionMSSQL

Xóa dòng bị trùng lắp

0guest asked on 2016/03/14 11:50:59

Làm thế nào để xóa những dòng bị trùng trên MS SQL
Thí dụ
Id      Name
1       A
1       A
2       B
3       C
3       C
4       D
MSSQL

Comments

There is no comment

Answers


0Hancock answer on 2016/03/24 10:56:48
Sample:
WITH CTE AS(
   SELECT *,
       RN = ROW_NUMBER()OVER(PARTITION BY [Id] ORDER BY [Id])
   FROM dbo.Table1
)
DELETE FROM CTE WHERE RN > 1

Comments

There is no comment

Please login to answer this question
Contact: