suppose i have table student contain only single column ID
And it value for ID is
ID
1
1
2
3
2
4
4
So now i want to delete duplicate row and display out put is
ID
1
2
3
4
So how i write query. Please help me
Thanks in advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vipan SharmaPosted Mar 19, 2016, 4:09 AM
AS
(
SELECT Id,ROW_NUMBER() OVER(PARTITION by Id ORDER BY Id)
AS duplicateRecCount
FROM dbo.student
)
--Now Delete Duplicate Records
DELETE FROM TempStudent
WHERE duplicateRecCount > 1
select * from student
Vipan SharmaPosted Mar 19, 2016, 5:34 AM
RAHUL PATILPosted Mar 19, 2016, 4:32 AM
Rajeev PunhaniPosted Mar 19, 2016, 4:05 AM
If the above solution is helpful then,accept the answer.