September 12, 2007 at 1:18 am
DELETE f
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY Col1 ORDER BY ID) AS RecID) AS f
WHERE RecID > 1
N 56°04'39.16"
E 12°55'05.25"
September 12, 2007 at 6:32 am
Hi Guys
This is my first post to this forum. Here is my solution .
I have table named duplicate in which RID is identity column and V1, V2, V3 other column which are having duplicate values.
I wrote this query
delete from duplicate where RID not in
( select a.RID from
( select min (RID) as RID , V1, V2, V3 from duplicate group by V1, V2, V3 ) a )
enjoy ....![]()
bharat Shah
September 12, 2007 at 8:16 am
Now... that's a bummer...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 13, 2007 at 7:47 am
So basically you deleted all of the rows that didn't have foreign key relationships?
I don't think using min(ID) would work since the ID column is a GUID right?
September 13, 2007 at 9:10 am
ok I have a fix that makes sense now...
I deleted out of my image table where manCode was equal to the manufacturer that had duplicate rows.
Then I re-insert the rows CORRECTLY this time and use an update statement to relate the tables back to each other.
I was fortunate enough to have back up of the data.
I guess sometimes its just better to start fresh rather than try to clean up a mess, and now that I look back on it this was the easiest way to do so. ![]()
and yes ryan the mid() doesn't work because of the GUID
thanks for everyones input
September 13, 2007 at 9:23 pm
Nice job, Zach... didn't realize that starting over was an option but I do thank you for the explanation of what you did ![]()
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply