I had previously penned down two popular snippets regarding deleting duplicate rows and counting duplicate rows. Today, we will examine another very quick code snippet where we will delete duplicate rows using CTE and ROW_NUMBER() feature of SQL Server 2005 and SQL Server 2008.
SQL SERVER – UDF – Remove Duplicate Chars From String
Few days ago, I received following wonderful UDF from one of this blog reader. This UDF is written for specific purpose of removing duplicate chars string from one large string. Virendra Chauhan, author of this UDF is working as DBA in Lutheran Health Network. CREATE FUNCTION dbo.REMOVE_DUPLICATE_INSTR (@datalen_tocheck INT,@string VARCHAR(255))…
Read MoreSQL SERVER – Count Duplicate Records – Rows
In my previous article SQL SERVER – Delete Duplicate Records – Rows, we have seen how we can delete all the duplicate records in one simple query. In this article we will see how to find count of all the duplicate records in the table. Following query demonstrates usage of…
Read MoreSQL SERVER – Delete Duplicate Records – Rows
Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN…
Read More