How to delete the duplicate rows from a table in SQL Server ??
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / sudha511
select distinct * into #temp from sampletbl
delete sampletbl
insert into sampletbl
select * from #temp
drop table #temp
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / himmat
delete from table name
having count(column name)>1
group by column name
| Is This Answer Correct ? | 15 Yes | 25 No |
How do we return a record set from a Stored Procedure in SQl server 2000?
how to control the amount of free space in your index pages? : Sql server database administration
Can you explain the disadvantages/limitation of the cursor?
Please explain go command in sql server?
What is database replicaion? What are the different types of replication you can set up in SQL Server?
5 Answers Aptech, HCL, Perpetual, SAIC,
How to check if a table is being used in sql server?
Please differentiate between a local and a global temporary table?
What is meant by datasource?
How to view existing indexes on an given table using sys.indexes?
What types of integrity are enforced by a foreign-key constraint
What is difference between clustered index and non clustered index?
explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)