Wrox Programmer Forums
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2009, 11:16 PM
Authorized User
 
Join Date: Jul 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delete Duplicate Rows

Hi There

I would like to know hoe to delete duplicate rows from a table eg

col1 col2 col3 col4 col5 col6 col7
HP 1 1 OCCUPIED 3 A CASKET
HP 1 1 OCCUPIED 3 B CASKET
HP 1 1 OCCUPIED 3 B CASKET
HP 1 1 OCCUPIED 3 C CASKET
HP 1 1 PRE-PURCH 3 D CASKET
HP 1 1 PRE-PURCH 3 E CASKET

I would like to delete all rows where col6 is the same ie B

Thanks

Greg
 
Old March 12th, 2009, 12:26 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=186
 
Old March 13th, 2009, 05:17 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DELETE f
FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY Col6 ORDER BY Col1) AS recID
FROM Table1) AS f
WHERE recID > 1





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you delete duplicate rows without using te subhasischakraborty SQL Server 2000 15 October 19th, 2007 06:51 AM
How to delete unique rows but with duplicate colum winder SQL Server 2005 3 January 3rd, 2007 04:57 PM
duplicate rows msrnivas Classic ASP Components 1 August 26th, 2004 02:07 AM
Detecting duplicate rows. Daniel Walker PHP Databases 6 June 21st, 2004 02:39 AM
Checking Duplicate values and delete rows ppenn Excel VBA 2 February 3rd, 2004 06:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.