I actually bloged about this earlier this month.  See here: 
http://www.ruslansivak.com/index.cfm/2007/1/10/Deleting-duplicate-rows-from-
SQL-Server


Russ
> -----Original Message-----
> From: Bruce Sorge [mailto:[EMAIL PROTECTED]
> Sent: Thursday, February 01, 2007 12:26 PM
> To: CF-Talk
> Subject: SQL QUestion
> 
> I have a lot of duplicate information in a table. I know how to query to
> find the dupes, but I am having problems with deleting them (there are
> thousands). I tried this:
> 
> DELETE
> FROM CODES
> WHERE Code =
> (SELECT Code,
> COUNT(Code) AS NumOccurrences
> FROM Codes
> GROUP BY Code
> HAVING ( COUNT(Code) > 1 ))
> 
> Now of of course even if this one did work, it just occured to me that it
> will not do what I want it to. What I want is to leave one instance of the
> code in the database and delete the duplicates only. Is this possible
> without me going line by line?
> 
> Thanks,
> 
> --
> Bruce Sorge
> 
> "I'm a mawg: half man, half dog. I'm my own best friend!"
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7 
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs 
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:268340
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to