🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: - Delete Multiple Rows?

#30
From: David Pledger
Date: Thu, 31 Oct 1996 00:00
41 lines
2322 bytes
There are lots of unique ways to do this, but the easiest with SQL Server is
to create a clustered index that ignores dup rows...  For example:

  create clustered nonunique index X on myTable(col1) with ignore_dup_row

This will delete ALL duplicate rows leaving one unique row in the
database.  Note that it deletes duplicate rows, not duplicate values
based on the column being indexed.  You will get a message stating 

  Warning:  deleted duplicate row.  Primary key is 'value'

Later,
David Pledger


Les Gainous (lesgainous@earthlink.net) wrote:
: 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

--
+==============================+=============================================+
| David W. Pledger             | S T R A T E G I C   D A T A   S Y S T E M S |
| davidp@lexis-nexis.com       |      PO Box 498, Springboro, OH  45066      |
| Custom Database Applications |        Phone: (800)253-5624 ext 2940        |
+==============================+=============================================+
Technical Details
Message-ID: <55b0n1$p16@mailgate.lexis-nexis.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3276F4A7.1842@earthlink.net>

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: davidp@meaddata.com (David Pledger)
Subject: Re: - Delete Multiple Rows?
Date: 1996/10/31
Message-ID: <55b0n1$p16@mailgate.lexis-nexis.com>
X-Deja-AN: 193481901
references: <3276F4A7.1842@earthlink.net>
followup-to: comp.databases.ms-sqlserver,comp.databases.theory,bit.databases.mssql-l,microsoft.public.sqlserver.programming
organization: Lexis-Nexis, Dayton OH
newsgroups: comp.databases.ms-sqlserver,comp.databases.theory,bit.databases.mssql-l,microsoft.public.sqlserver.programming