Write a query to delete duplicate records in SQL SERVER
Answer Posted / senthilsjc
This query delete duplicate records(but not delete both
duplicate)
set rowcount 1
delete yourtable
from yourtable a
where (select count(*) from yourtable b where b.name=a.name
and b.age=a.age)>1
while @@rowcount >0
delete yourtable
from yourtable a
where(select count(*) from yourtable b b.name=a.name and
b.age=a.age)>1
set rowcount 0
| Is This Answer Correct ? | 6 Yes | 12 No |
Post New Answer View All Answers
How to defragment table indexes?
What are the differences between left join and inner join in sql server?
i have made a project i vb.net n created a .exe of it after installing it in to any pc, the database (sql express) is not geting accesed i.e the aplication cuts the link of the database, so plz help in this matter.
While you are inserting values into a table with the insert into .. Values option, does the order of the columns in the insert statement have to be the same as the order of the columns in the table?
What is the index requirement in SQL Azure?
What program is used to store the data source file?
What is resource governor in sql server?
How does SSIS(Sql Server Integration Services) deffer from DTS(Data Transformation Services)?
Tell me what do you understand by a view? What does the with check option clause for a view do?
Is sql server 2016 free?
What are various limitations of the views?
Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.
What is save transaction and save point?
You want to generate a report that is formatted as a chart. Can you use the report wizard to create such a report?
How extra digits are handled with numeric data type literals?