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 |
What is dimension table? : sql server analysis services, ssas
How to insert and update data into a table with "insert" and "update" statements?
What is Query Execution Plan? How does it help optimize or tune a database driven application?
What is default port number for sql server 2000?
Explain what is cte (common table expression)?
what is a transaction? : Sql server database administration
Is it true, that there is no difference between a rule and a check constraint?
How do I partition a table in sql server?
Tell me about pre-defined functions of sql?
How to create dbo table in sql server?
Which are new data types introduced in sql server 2008?
How to create an index on a view?
Oracle (3253)
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)