Hi all,
I have a table with two field
age location
20 A
22 B
20 A
22 B
23 C
Now i want to delete duplicate record from table through sql query if any one know then please help me.
Thanks in advance.....................
How to Delete duplicate record from table in sql server 2008
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

venkata kumarRank #5,034 · 314 reputationPosted Mar 9, 2013, 12:09 AM EST
try this
DELETEFROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)
DELETEFROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)
Sandeep Mhatre16 reputationPosted Apr 7, 2013, 9:18 AM EDT
/* Delete Duplicate records */
WITH CTE (Col1,RowNum)
AS
(
SELECT Col1,
ROW_NUMBER() OVER(PARTITION BY Col1 ORDER BY Col1) AS RowNum
FROM DuplicateRcordTable
)
DELETE
FROM CTE
WHERE RowNum > 1
GO
http://sandeepmhatre.blogspot.com/2013/03/common-table-expressions.htmlSatyapriya NayakRank #47 · 31.5K reputationPosted Apr 7, 2013, 9:58 AM EDT
FROM TestTable
WHERE TestTable.%%physloc%%
NOT IN (SELECT MIN(b.%%physloc%%)
FROM TestTable b
GROUP BY b.column1, b.Column2);
http://www.codeproject.com/Tips/159881/How-to-remove-duplicate-rows-in-SQL-Server-2008-wh