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 |
Does group by or order by come first?
Explain the use of keyword with encryption. Create a store procedure with encryption?
What are the different subsets of sql?
Define right outer join in sql server joins?
What is SubQuery in SQL Server 2008
What are the hotfixes and patches in sql server?
How do you load large data to the SQL server database?
Describe the functionalities that views support.
What are recommended options to be used while using db mirroring? : sql server database administration
How data can be copied from one table to another table?
Can the “if update (colname)” statement be used in a delete trigger?
Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attribute defined on it. So how can we insert data in this table. I am reframing my question, that how can we make the table to increment the column "OrderID" value several times???
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)