if 3 duplicate records in a table,i want to delete 2 duplicate
records by keeping 1 duplicate and 1 original as it is,how?
Answer Posted / mohamed zunu
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')
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 ? | 9 Yes | 1 No |
Post New Answer View All Answers
How you can get the list of largest tables in a database?
What is stretch database in sql server?
When would you use a before or after trigger?
List out different types of normalizations in sql server and explain each of them?
What is for xml in sql server?
What is the need for indexing?
How to provide values to stored procedure parameters in ms sql server?
How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?
In what sequence sql statement is processed?
What’s the distinction between dropping a info and taking a info offline?
What are the database roles? : sql server security
Explain the cursor lock types?
How to transfer a table from one schema to another?
What is the difference between coalesce() & isnull()?
How can you list all the table constraints in a database?