🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.ms-sqlserver
Article #29

Re: - Delete Multiple Rows?

#29
From: Les Gainous
Date: Thu, 31 Oct 1996 00:00
71 lines
3070 bytes
Louis,

Yea, that's the whole idea--to not delete all the rows that are
duplicated, just the subsequent rows.

Let me know!
-- 
 Les Gainous, lesgainous@earthlink.net

 Visit my web page at
      http://home.earthlink.net/~lesgainous

 Looking for a Client-Server job in California?
      http://home.earthlink.net/~lesgainous/jobs.html


Louis Davidson wrote:
> 
> Try     select          col1,
>                         count(*)
>         into            #hold
>         from            myTable
>         group by        col1
>         having          count(*) > 1
> 
> delete  myTable
> from    myTable, #hold
> where   myTable.col1 = #hold.col1
> 
> The only problem is that this will delete both rows. There are better
> solutions that will not, if you want I could go through them.
> 
> --
> ----------------------------------------------------------------------------
> ------------
> Louis Davidson
> Christian Broadcasting Network
> 
> work: louis.davidson@cbn.org
> home: vallou@infi.net
> virtual address: http://members.aol.com/vallou
> 
> "I used to think anyone doing anything weird was weird.
> I suddenly realized that anyone doing anything weird wasn't
> weird at all and that it was the people saying they were weird
> that were weird."
> Paul McCartney
> ----------------------------------------------------------------------------
> ------------
> 
> Les Gainous <lesgainous@earthlink.net> wrote in article
> <3276F4A7.1842@earthlink.net>...
> > I'm using MS-SQL Server 6.5 (but any generic SQL syntax would be
> > appreciated):
> >
> > How can I delete multiple occurrences of a row within a table. I know
> > how to display the rows which are duplicated:
> >
> >       select          col1,
> >                       count(*)
> >       from            myTable
> >       group by        col1
> >       having          count(*) > 1
> >
> > But now that I have that listing, how can I delete the second (or third,
> > or...) occurrence of the row--preserving the first occurrence.
> >
> > Thanks in advance!
> > Les
> >
Technical Details
Message-ID: <3278D229.5729@earthlink.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3276F4A7.1842@earthlink.net> <01bbc734$69c95690$79431a9f@louman-s-home>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f4bf8,e42b60ff2edc4f24
X-Google-Attributes: gidf4bf8,public
X-Google-Thread: 11301e,e42b60ff2edc4f24
X-Google-Attributes: gid11301e,public
X-Google-Thread: f6611,e42b60ff2edc4f24
X-Google-Attributes: gidf6611,public
X-Google-Thread: 104de1,e42b60ff2edc4f24
X-Google-Attributes: gid104de1,public
From: Les Gainous <lesgainous@earthlink.net>
Subject: Re: - Delete Multiple Rows?
Date: 1996/10/31
Message-ID: <3278D229.5729@earthlink.net>
X-Deja-AN: 193446620
references: <3276F4A7.1842@earthlink.net> <01bbc734$69c95690$79431a9f@louman-s-home>
to: Louis Davidson <vallou@infi.net>
content-type: text/plain; charset=us-ascii
organization: The Gainous Windows NT Server
mime-version: 1.0
reply-to: lesgainous@earthlink.net
newsgroups: comp.databases.ms-sqlserver,comp.databases.theory,bit.databases.mssql-l,microsoft.public.sqlserver.programming
x-mailer: Mozilla 3.0Gold (Win95; I)