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 what are commit and rollback in sql?
How to write a query with a left outer join in ms sql server?
Distinguish between commit and rollback?
What is ms sql server reporting services?
Which autogrowth database setting is good?
What is filtered index?
What do you do in data exploration
Can you explain what is indexed view? How to create it?
Why is there a performance difference between two similar queries where one uses union and the other uses union all?
Explain few of the new features of sql server 2008 management studio
What is after dml trigger?
How can you transfer data from a text file to a database table? Or how can you export data from a table to a comma delimited (csv) file? Or how can you import data from ms access to a table in a database? Or how can you export data from a table to an excel file?
What are two difference between sql azure and azure tables?
What are scalar functions in sql?
What is default port number for sql server 2000?