How to delete the duplicate rows from a table in SQL Server ??
Answer Posted / vnreddy
create table sampletbl(id int,name varchar(100))
insert into sampletbl values(1,'aa')
insert into sampletbl values(1,'aa')
insert into sampletbl values(1,'aa')
insert into sampletbl values(2,'bb')
insert into sampletbl values(2,'bb')
with cte as(
select ROW_NUMBER() over (partition by id order by id) as r_no,* from sampletbl)
delete from cte where r_no>1
select * from sampletbl
| Is This Answer Correct ? | 10 Yes | 2 No |
Post New Answer View All Answers
Explain the flow of creating a cube? : sql server analysis services, ssas
Do comments need to go in a special place in sql server 2005?
what's the difference between delete table and truncate table commands? : Sql server database administration
Explain system views?
How column data types are determined in a view?
How to find Duplicate Records In table?
Can you explain what are various ways to enhance the ssrs report?
what is create database syntax? : Sql server database administration
Explain powershell included in sql server 2008?
Which sql server table is used to hold the stored procedure script?
Explain in brief how sql server enhances scalability of the database system?
Can You Use A Stored Procedure To Provide Data To An Ssrs Report?
According to you what goes into making the best database administrator? : sql server database administration
What is a linked server in sql server?
What is the maximum size of a dimension? : sql server analysis services, ssas