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 are the differences between decimal and float in ms sql server?
What is outer join in sql server joins?
How to create a view on an existing table in ms sql server?
Do you know what are the differences between lost updates and uncommitted dependencies?
explain different types of jions with examples briefly?
if we have a column (Key) in a table. and values of that column is Key 1 1 1 2 2 3 3 4 4 5 5 5 and we want to show the data after query..like.. 1(3) 2(3) 3(2) 4(2) 5(3) how many times a single term comes..
17 Answers 3i Infotech, Rolta, TCS,
Can you explain what is indexed view? How to create it?
What is the difference between osql and query analyzer?
Difference between Inner vs outer joins?
What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
How do I view views in sql server?
Do you know what is similarity and difference between truncate and delete in sql?
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)