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.
| Author |
Topic |
|
pingili07656
Starting Member
3 Posts |
Posted - 2012-08-09 : 16:13:53
|
| Hi all i have a table with duplicate values like below2010-06-30, 00:00:00.000, 2010-06-30 00:00:00.000, 2010-06-30 23:44:00.000, 2010-07-02 12:09:00.000 , NULL, 312734,495789, , 52i523AND 2010-06-30, 00:00:00.000, 2010-06-30 00:00:00.000, 2010-06-30 23:44:00.000, 2010-07-02 12:09:00.000 , NULL, 312734,495789,NULL , 52i523I would like to have only the below record in my table 2010-06-30, 00:00:00.000, 2010-06-30 00:00:00.000, 2010-06-30 23:44:00.000, 2010-07-02 12:09:00.000 , NULL, 312734,495789, , 52i523Any help is appriciated. Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-09 : 16:17:37
|
| [code]SELECT field1,field2,....FROM(SELECT ROW_NUMBER() OVER (PARTITION BY field1,field2,... ORDER BY PK) AS Seq,*FROM table)tWHERE Seq=1[/code] field1,field2,... are set columns with same value for multiple rows and pk is primary keyonce you do above and confirm that you get correct unique records then convert select logic to delete to remove duplicate entries[code]DELETE tFROM(SELECT ROW_NUMBER() OVER (PARTITION BY field1,field2,... ORDER BY PK) AS SeqFROM table)tWHERE Seq>1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|