﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / delete duplicates / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 08:45:37 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>A simple way to delete dups that works on versions earlier than 2005 is:[code="sql"]DELETE EMPFROM Employees EMPINNER JOIN  (SELECT MIN(EmpID) AS EmpID, EmpName   FROM Employees   GROUP BY EmpName   HAVING COUNT(*) &amp;gt; 1  ) AS DUP ON    EMP.EmpName = DUP.EmpName    AND EMP.EmpID &amp;lt;&amp;gt; DUP.EmpID[/code]Todd Fifield</description><pubDate>Fri, 25 Mar 2011 12:14:45 GMT</pubDate><dc:creator>tfifield</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Can be done using  temp table for your referenceSELECT EmpID,EmpName INTO #tempFROM EmployeesGROUP BY EmpID,EmpNameHAVING COUNT(*)&amp;gt;1DELETE Employees FROM Employees a INNER JOIN #temp b ONa.EmpID=b.EmpIDINSERT INTO Employees(EmpID,EmpName)SELECT EmpID,EmpName FROM #temp</description><pubDate>Thu, 24 Mar 2011 23:07:51 GMT</pubDate><dc:creator>Smash125</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Can be done using temp tableSELECT EmpID,EmpName INTO #tempFROM EmployeesGROUP BY EmpID,EmpNameHAVING COUNT(*)&amp;gt;1DELETE Employees FROM Employees a INNER JOIN #temp b ONa.EmpID=b.EmpIDINSERT INTO Employees(EmpID,EmpName)SELECT EmpID,EmpName FROM #temp</description><pubDate>Thu, 24 Mar 2011 23:06:33 GMT</pubDate><dc:creator>Smash125</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>I have found good article on deleting duplicate record. You can see [url=http://www.doyouknow.in/Articles/Programming/MS-SQL/T-SQL-Query-To-Delete-Duplicate-Records-Among-Identical-Rows-In-A-Table.aspx]T-SQL Query To Delete Duplicate Records Among Identical Rows In A Table[/url]....</description><pubDate>Thu, 24 Mar 2011 05:56:35 GMT</pubDate><dc:creator>Jimit Shah</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Because you say your table is big and you don't seem to have the right indexes, you can use the following as an alternative to doing a select distinct or a row_number() over():Create a new table with a unique index on the colums where you don't want duplicates but use the IGNORE_DUP_KEY = ON option (see [url=http://msdn.microsoft.com/en-us/library/ms188388.aspx]http://msdn.microsoft.com/en-us/library/ms188388.aspx[/url]). Copy all records from the old table to the new one, drop the old table and rename the new one.Done.</description><pubDate>Thu, 28 Jan 2010 03:08:06 GMT</pubDate><dc:creator>wschampheleer</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Yes the CTE technique is the best to eliminate your duplicate values...so just do it!</description><pubDate>Thu, 28 Jan 2010 02:21:15 GMT</pubDate><dc:creator>Dugi</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>[code="sql"]DECLARE @tbl TABLE(	EMPID			INT,	EmpName			VARCHAR(100))INSERT INTO @tblSELECT1, 'aaa'UNION ALLSELECT1, 'aaa'UNION ALLSELECT2, 'aaa'UNION ALLSELECT3, 'bbb'UNION ALLSELECT2, 'bbb'DELETE D FROM(SELECT	ROW_NUMBER() OVER(PARTITION BY EMPID,EmpName ORDER BY EMPID) AS ROWS,	EMPID,	EmpNameFROM	@tbl)DWHERE	ROWS	&amp;gt; 1SELECT * FROM @tbl	[/code]</description><pubDate>Wed, 27 Jan 2010 22:56:39 GMT</pubDate><dc:creator>Mitesh Oswal</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>There are already a couple of solutions proposed that use a CTE.  I would recommend picking a CTE solution.</description><pubDate>Wed, 27 Jan 2010 17:23:22 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Here is a CTE based solution....; WITH EmployeesCTEAS(        SELECT  ROW_NUMBER() OVER( PARTITION BY EmpID, EmpName ORDER BY EmpID ) AS RowNumber,                        EmpID, EmpName        FROM    Employees)DELETEFROM    EmployeesCTEWHERE   RowNumber != 1--RameshThis is elegant...</description><pubDate>Wed, 27 Jan 2010 17:10:55 GMT</pubDate><dc:creator>rcassis-1001343</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>if the table is small then create a new table with the distinct values and then drop the old table and rename the new table to the Old table name.Thanks -- Vijaya Kadiyalahttp://dotnetvj.blogspot.com</description><pubDate>Mon, 09 Feb 2009 08:58:46 GMT</pubDate><dc:creator>Vijaya Kadiyala</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Here is a CTE based solution....[code]; WITH EmployeesCTEAS(	SELECT	ROW_NUMBER() OVER( PARTITION BY EmpID, EmpName ORDER BY EmpID ) AS RowNumber,			EmpID, EmpName	FROM	Employees)DELETEFROM	EmployeesCTEWHERE	RowNumber != 1[/code]</description><pubDate>Mon, 09 Feb 2009 07:14:49 GMT</pubDate><dc:creator>Ramesh Saive</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Hi Thank you for ur reply,in that EMPID dont have primary key is it possible that one because it is very big database plz help me</description><pubDate>Mon, 09 Feb 2009 03:51:14 GMT</pubDate><dc:creator>kumar99ms</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>One common method is to move the data into another table (same structure as emp table)and drop the original emp table and rename the new table.Create table NewEmp.....SELECT DISTINCT EmpID,Empname INTO NewEmpFrom EmpDrop Empsp_rename 'NewEmp' , 'Emp'</description><pubDate>Mon, 09 Feb 2009 03:43:49 GMT</pubDate><dc:creator>ChiragNS</dc:creator></item><item><title>RE: delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>A good method for deleting duplicates is using CTE.it is nicely explained in the msdn site. http://msdn.microsoft.com/en-us/library/ms190766(SQL.90).aspxHope the above helps.Sriram</description><pubDate>Mon, 09 Feb 2009 03:39:24 GMT</pubDate><dc:creator>Sriram-288748</dc:creator></item><item><title>delete duplicates</title><link>http://www.sqlservercentral.com/Forums/Topic652644-338-1.aspx</link><description>Hi Every body,I have one table EmployeesEmpID   EmpName1               aaa1               aaa2               aaa3                bbb2              bbbHere in my table dont have primary key to that EMPID how can i eliminate duplicates in my table am using self joins but it is not working could any body help me plz really appreciate to youThanks</description><pubDate>Mon, 09 Feb 2009 03:33:45 GMT</pubDate><dc:creator>kumar99ms</dc:creator></item></channel></rss>