Showing posts with label repeated. Show all posts
Showing posts with label repeated. Show all posts

Wednesday, March 7, 2012

How to delete repeated entries from table using T-SQL statement

Hi Friends..

I want delete repeated entries which comes twice in a table. How to delete that extra entry and keep each single entry using T-SQL statement(SQL server 2000). Please give me the example.

Thanks & Regards,
Ravi.Hi,

You may select distinct the duplicate entry and save it in a temporary table, then delete the double entry to the main table and insert the content of the temporary table to the main table.|||Hi,

Thank you for giving solution, but still I don't know how to do that, can you send me code and e.g. It will help me for understanding. I hope you will give this solution very soon.

Thanks & Regards,
Ravi.

Sunday, February 19, 2012

How to Delete ?

hi,

How to delete the following repeated data ?

my table :
Name Salary
--
Abc 20000
Abc 10000
CDE 01000
XYZ 12000
VID 30233
XYZ 40000

from the above table I want to delete repeated record 'Abc' and XYZ so that I should have the following records

Name Salary
--
Abc 20000
CDE 01000
XYZ 12000
VID 30233

Is it possible ?

Adv. thanks
bye
muralidharan T RYou need to be specific about which rows you wish to delete. If, for example, you want to delete all but the highest salary for each name:

delete from myTable
where Salary < (
select max(Salary) from myTable as T2
where T2.Salary > myTable.Salary
)

Steve Kass
Drew University
SQL Server MVP