Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to delete duplicate records in table?

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2009-06-01 : 08:46:35
i have table with id,empnam,age i want to delete the duplicate records base id.
how to do it?

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-06-01 : 08:50:42
Mr Anand or Miss Subha,

Weather the id column id Primary key?


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2009-06-01 : 09:06:17
Jesus. Is google broken or something? There must be a billion answers to this on this forum alone.

http://lmgtfy.com/?q=how+to+delete+duplicate+records+in+table
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-06-01 : 09:18:09
delete from mytable where id not in(
select max(id) as id from mytable m group by name,num )


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled
Go to Top of Page

subhaoviya
Posting Yak Master

135 Posts

Posted - 2009-06-02 : 03:41:13
quote:
Originally posted by senthil_nagore

delete from mytable where id not in(
select max(id) as id from mytable m group by name,num )


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled



thanks senthil
its working fine
Go to Top of Page
   

- Advertisement -