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
Why do we use functions?
What is analysis service repository?
How to sort query output in descending order in ms sql server?
How to verify the port number of the sql server?
What are the new features in SQL Server 2005 when compared to SQL Server 2000?
Is it true that rules do not apply to data already existing in a database at the time the rule is created?
What is proper subset of candidate key?
what types of replication are supported in sql server? : Sql server database administration
Explain indexes disadvantages?
Describe how to use linked server?
What do you mean by data manipulation language?
How to configure and test odbc dsn settings?
What are the advantages of sql stored procedure?
What is a trigger and types of a trigger?
I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration