Home All Groups Group Topic Archive Search About
Author
13 May 2005 8:20 PM
Mike
I have a table with 1 column (email). I use this table to import values.
I want to delete duplicate emails in this. How can I do it?

Author
13 May 2005 8:28 PM
Armando Prato
http://www.aspfaq.com/show.asp?id=2431

Show quote
"Mike" <M***@discussions.microsoft.com> wrote in message
news:2CD2121B-6865-4037-9A24-D64B362E7616@microsoft.com...
> I have a table with 1 column (email). I use this table to import values.
> I want to delete duplicate emails in this. How can I do it?
Author
13 May 2005 11:10 PM
CBretana
Declare @EMs Table (EM VarChar(500))
Insert @EMs Select Distinct Email from EmailTable
Delete EmailTable
Insert EmailTable Select * From @EMs

Show quote
"Mike" wrote:

> I have a table with 1 column (email). I use this table to import values.
> I want to delete duplicate emails in this. How can I do it?
Author
13 May 2005 11:46 PM
CBretana
Disregard the last... If something goes wrong you will have lost the data. 
To protec yourself, backup the table to another table (a Copy) first. 
Then,  Instead of using a table variable, use a temporary "permanent"  table

Create Table zEmails (Email Varchar(500))
Insert zEmails Select Distinct Email form EmailTable
Delete EmailTable
Insert EmailTable Select EMail from zEmails
Show quote
"Mike" wrote:

> I have a table with 1 column (email). I use this table to import values.
> I want to delete duplicate emails in this. How can I do it?

AddThis Social Bookmark Button