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 |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2008-06-23 : 14:33:55
|
i have a log table that contains multiple entries or rows.the rows contain 12 coloumns . My task is to remove duplicate rows in which all 12 coloumns are identical in the rows leaving only one row in the table.how can i do it ?thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-23 : 23:53:55
|
[code]DELETE tFROM Table tINNER JOIN(SELECT field1,field2,...,field12FROM TableGROUP BY field1,field2,...,field12HAVING COUNT(*) >1)tmpON tmp.field1=t.field1AND tmp.field2=t.field2AND....AND tmp.field12=t.field12LEFT JOIN (select field1,field2,...,field12,MIN(PK) AS MinPK FROM Table GROUP BY field1,field2,...,field12)tmp2ON tmp2.MinPK=t.PKWHERE tmp2.MinPK IS NULL[/code] |
 |
|
|
|
|
|
|