Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Removing Duplicate Records


Message #1 by "Vittal_setty" <Vittal_setty@i...> on Thu, 9 Jan 2003 09:49:53 +0530
There are a few suggestions here:
http://www.sqlteam.com/item.asp?ItemID=3D3331

but many of them may be performance prohibitive. The comments on the 
article also have some suggestions:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=3D6256

If you really can't do anything with temp tables etc, then looping 
through the table using a cursor may be a good *last* option. Something 
in the form:

--loop til at EOF
	IF EXISTS (SELECT NULL FROM Table WHERE <insert criteria>
	BEGIN
		DELETE TABLE <table name> where <criteria> AND ID <> <current ID>
	END

--end loop

regards
David Cameron
nOw.b2b
dcameron@i...

> -----Original Message-----
> From: Vittal_setty [mailto:Vittal_setty@i...]
> Sent: Thursday, 9 January 2003 3:20 PM
> To: sql language
> Subject: [sql_language] Removing Duplicate Records
>
>
> Hi All,
>
>
> In my Table of 100 Million records, there are some 2 Million
> completely
> Duplicate Records, which I have. I need a query which would
> delete only
> the Duplicate records & not the original record.
>
> A crude way would be to get all distinct records in a temp table, drop
> the existing table, and create it again using the temp table.
>  The size
> of data prohibits me from going for this approach
>
> Please guide me if there is a more efficient way of accomplishing this
> task.
>
> Thanks for your help in advance
> Please copy to my mail id as well.
>
> Regards
> Vittal
>
>
>

  Return to Index