Home:ALL Converter>Delete duplicate id and Value ROW using SQL Server 2008 R2

Delete duplicate id and Value ROW using SQL Server 2008 R2

Ask Time:2012-12-08T05:57:15         Author:Joy1979

Json Formatter

In SQL Server 2008 R2 I added two duplicate ID and record in my table. When I try to delete one of the last two records I receive the following error.

The row values updated or deleted either do not make the row unique or they alter multiple rows.

The data is:

7   ABC         6
7   ABC         6
7   ABC         6
8   XYZ         1
8   XYZ         1
8   XYZ         4
7   ABC         6
7   ABC         6

I need to delete last two records:

7   ABC         6
7   ABC         6

I have been trying to delete last 2 record using the feature "Edit the Top 200 rows" to delete this duplicate id but get the error above.

Any help is appreciated. Thanks in advance:)

Author:Joy1979,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/13771644/delete-duplicate-id-and-value-row-using-sql-server-2008-r2
RichardTheKiwi :

Since you have given no clue whatsoever that there are other columns in the table, assuming your data is in 3 columns A,B,C, you can delete 2 rows using:\n\n;with t as (\n select top(2) *\n from tbl\n where A = 7 and B = 'ABC' and C = 6\n)\nDELETE t;\n\n\nThis will arbitrarily match two rows based on the conditions, and delete them.",
2012-12-07T22:05:44
yy