|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
delete duplicate rowsI 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?
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? 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? 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? |
|||||||||||||||||||||||