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 user defined datatypes? : Sql server database administration
in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Tell me about normalization in DBMS.
Is it possible to allow NULL values in foreign key? I s it possible to use different constraints for the same column in the table (i.e) (id int NOT NULL,UNIQUEUE)
Is foreign key unique?
What is nolock?
Determine when to use stored procedure to complete sql server tasks?
How to create stored procedures with parameters in ms sql server?
How important do you consider cursors or while loops for a transactional database?
Write the queries for commands like Create Table, Delete table, Drop Table etc.
0 Answers HPCL, Hughes Systique Corporation,
In which files does sql server actually store data?
Explain Trigger with an example?
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)