Ask a Question related to ASP Database, Design and Development.
-
dave #1
how to eliminate duplicate rows?
Hi
I have one table with two field in sql server 2000.
Table data looks like this:
Field1 Field2
Admin Active
Admin Passive
Sales Active
Sales Passive
Systems Active
Systems Active
Admin Passive
Sales Passive
Can any one suggest how to write sql query to eliminate
duplicates records(duplicate rows) from the table???
Thanx
dave
dave Guest
-
MySql UPDATE problem with duplicate rows
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary... -
How to delete duplicate rows?
This one must be obvious for most here. I have a 170 million rows table from which I want to eliminate duplicate "would be" keys and leave only... -
Eliminate gap between table rows?
I made my first PHP page that uses includes. http://php.didah.com/main.php But I can't get rid of a gap (about 5 pixels) between the table rows. ... -
How to eliminate margin
On a page I have a table with a single <tr> & <td> containing a flash movie and some graphics. With the flash file, there is a 3-4 pixel white space... -
Could anyone help me to remove duplicate rows?
I have a table that has more than 1 milion rows so practically it is impossible to remove all duplicate rows by hand. Could you help me to remove... -
Aaron [SQL Server MVP] #2
Re: how to eliminate duplicate rows?
SELECT column1, column2 FROM table GROUP BY column1, column2
--
[url]http://www.aspfaq.com/[/url]
(Reverse address to reply.)
"dave" <anonymous@discussions.microsoft.com> wrote in message
news:2251b01c45ca4$c2611230$a001280a@phx.gbl...> Hi
> I have one table with two field in sql server 2000.
> Table data looks like this:
>
> Field1 Field2
>
> Admin Active
> Admin Passive
> Sales Active
> Sales Passive
> Systems Active
> Systems Active
> Admin Passive
> Sales Passive
>
> Can any one suggest how to write sql query to eliminate
> duplicates records(duplicate rows) from the table???
> Thanx
> dave
>
Aaron [SQL Server MVP] Guest
-
dave #3
Re: how to eliminate duplicate rows?
Thanx Aaron
Result shows distinct records that I need to keep in the
table. But how can I delete the rest of them?
Dave
column2>-----Original Message-----
>SELECT column1, column2 FROM table GROUP BY column1,message>
>--
>[url]http://www.aspfaq.com/[/url]
>(Reverse address to reply.)
>
>
>
>
>"dave" <anonymous@discussions.microsoft.com> wrote in>news:2251b01c45ca4$c2611230$a001280a@phx.gbl...>>> Hi
>> I have one table with two field in sql server 2000.
>> Table data looks like this:
>>
>> Field1 Field2
>>
>> Admin Active
>> Admin Passive
>> Sales Active
>> Sales Passive
>> Systems Active
>> Systems Active
>> Admin Passive
>> Sales Passive
>>
>> Can any one suggest how to write sql query to eliminate
>> duplicates records(duplicate rows) from the table???
>> Thanx
>> dave
>>
>
>.
>dave Guest
-
Aaron [SQL Server MVP] #4
Re: how to eliminate duplicate rows?
Oh, you actually want to delete them? My first suggestion would be to
create a second table, insert the results of the GROUP BY, then add a
primary key. Drop the old table, rename the new one to the old name.
--
[url]http://www.aspfaq.com/[/url]
(Reverse address to reply.)
"dave" <anonymous@discussions.microsoft.com> wrote in message
news:21f4401c45ca9$d72e4a20$a301280a@phx.gbl...> Thanx Aaron
> Result shows distinct records that I need to keep in the
> table. But how can I delete the rest of them?
> Dave
Aaron [SQL Server MVP] Guest
-
dave #5
Re: how to eliminate duplicate rows?
any other alternatives?
cant do it using single sql statment????
Dave
suggestion would be to>-----Original Message-----
>Oh, you actually want to delete them? My firstBY, then add a>create a second table, insert the results of the GROUPthe old name.>primary key. Drop the old table, rename the new one tomessage>
>--
>[url]http://www.aspfaq.com/[/url]
>(Reverse address to reply.)
>
>
>
>"dave" <anonymous@discussions.microsoft.com> wrote inthe>news:21f4401c45ca9$d72e4a20$a301280a@phx.gbl...>> Thanx Aaron
>> Result shows distinct records that I need to keep in>>> table. But how can I delete the rest of them?
>> Dave
>
>.
>dave Guest
-
Aaron [SQL Server MVP] #6
Re: how to eliminate duplicate rows?
No, because you can't tell a DELETE statement to delete this row:
Admin Passive
But not this row:
Admin Passive
Because it can't tell them apart. This is one of the dangers you face when
you neglect to choose a primary key.
Another way to do it would be to add an IDENTITY column to the table, and
then see [url]http://www.aspfaq.com/2431[/url]
--
[url]http://www.aspfaq.com/[/url]
(Reverse address to reply.)
"dave" <anonymous@discussions.microsoft.com> wrote in message
news:225d401c45ccc$05b77750$a001280a@phx.gbl...> any other alternatives?
> cant do it using single sql statment????
> Dave
>> suggestion would be to> >-----Original Message-----
> >Oh, you actually want to delete them? My first> BY, then add a> >create a second table, insert the results of the GROUP> the old name.> >primary key. Drop the old table, rename the new one to> message> >
> >--
> >[url]http://www.aspfaq.com/[/url]
> >(Reverse address to reply.)
> >
> >
> >
> >"dave" <anonymous@discussions.microsoft.com> wrote in> the> >news:21f4401c45ca9$d72e4a20$a301280a@phx.gbl...> >> Thanx Aaron
> >> Result shows distinct records that I need to keep in> >> >> table. But how can I delete the rest of them?
> >> Dave
> >
> >.
> >
Aaron [SQL Server MVP] Guest
-
Jeff Cochran #7
Re: how to eliminate duplicate rows?
On Sun, 27 Jun 2004 21:54:41 -0700, "dave"
<anonymous@discussions.microsoft.com> wrote:
If you have no primary key, how would you identify *which* is the>any other alternatives?
duplicate? :)
The best (safest) method is what Aaron suggested. SELECT DISTINCT to>cant do it using single sql statment????
a new table, drop the old table and rename the new one.
Naturally, this assumes this table has no interdependencies with any
other tables, but it would be tough for any other table to use this
one without a primary key anyway. Your database design may change the
way you need to accomplish this. In the future, you could use a
primary key consisting of the two columns in order to ensure no
duplication exists.
Jeff
>suggestion would be to>>-----Original Message-----
>>Oh, you actually want to delete them? My first>BY, then add a>>create a second table, insert the results of the GROUP>the old name.>>primary key. Drop the old table, rename the new one to>message>>
>>--
>>[url]http://www.aspfaq.com/[/url]
>>(Reverse address to reply.)
>>
>>
>>
>>"dave" <anonymous@discussions.microsoft.com> wrote in>the>>news:21f4401c45ca9$d72e4a20$a301280a@phx.gbl.. .>>> Thanx Aaron
>>> Result shows distinct records that I need to keep in>>>>> table. But how can I delete the rest of them?
>>> Dave
>>
>>.
>>Jeff Cochran Guest
-
dave #8
Re: how to eliminate duplicate rows?
Thanx Aaron
I added auto number primary key and referred that article
tht you suggested.
It solved my problem exactly what I was looking for.
Once again,
Thanx
Dave
this row:>-----Original Message-----
>No, because you can't tell a DELETE statement to deletedangers you face when>
>Admin Passive
>
>But not this row:
>
>Admin Passive
>
>Because it can't tell them apart. This is one of theto the table, and>you neglect to choose a primary key.
>
>Another way to do it would be to add an IDENTITY columnmessage>then see [url]http://www.aspfaq.com/2431[/url]
>
>--
>[url]http://www.aspfaq.com/[/url]
>(Reverse address to reply.)
>
>
>
>
>"dave" <anonymous@discussions.microsoft.com> wrote into>news:225d401c45ccc$05b77750$a001280a@phx.gbl...>> any other alternatives?
>> cant do it using single sql statment????
>> Dave
>>>> suggestion would be to>> >-----Original Message-----
>> >Oh, you actually want to delete them? My first>> BY, then add a>> >create a second table, insert the results of the GROUP>> >primary key. Drop the old table, rename the new one>>> the old name.>> message>> >
>> >--
>> >[url]http://www.aspfaq.com/[/url]
>> >(Reverse address to reply.)
>> >
>> >
>> >
>> >"dave" <anonymous@discussions.microsoft.com> wrote in>> the>> >news:21f4401c45ca9$d72e4a20$a301280a@phx.gbl...
>> >> Thanx Aaron
>> >> Result shows distinct records that I need to keep in>> >> table. But how can I delete the rest of them?
>> >> Dave
>> >
>> >
>> >.
>> >
>
>.
>dave Guest



Reply With Quote

