---
title: "How to delete duplicate rows based on single column value in MSSQL?"  
description: "How to delete duplicate rows based on single column value in MSSQL?"  
author: "Ashutosh Patel"  
published: 2025-02-28  
updated: 2025-03-01  
canonical: https://www.mindstick.com/forum/161178/how-to-delete-duplicate-rows-based-on-single-column-value-in-mssql  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# How to delete duplicate rows based on single column value in MSSQL?

How to [delete duplicate](https://www.mindstick.com/forum/34367/delete-duplicate-rows-in-sql) rows based on [single column](https://www.mindstick.com/forum/159327/how-to-set-all-values-in-a-single-column-mysql-query) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) in [MSSQL](https://www.mindstick.com/forum/168/join-in-mssql-server-2005)?

## Replies

### Reply by Khushi Singh

All three viable approaches to [delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax) [duplicate rows](https://www.mindstick.com/forum/157765/how-to-remove-duplicate-rows-in-sql) in single-[column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) values within **MS SQL** Server involve using **Common Table Expressions (CTE)** with `ROW_NUMBER()` or the combination of the `DELETE` query with a subquery and grouping by `HAVING`.

The **CTE (Common Table Expression)** together with `ROW_NUMBER()` forms an effective method for this task. You need to start by adding row numbers to each duplicate record according to the prominent duplicated field. The query retains the row with the minimum assigned number and then deletes all other duplicate rows.

You can implement the `DELETE` command with a subquery to locate duplicates through a comparison of a unique row identifier. Through this approach, the initial duplicate records remain untouched but extra duplicate entries will be automatically removed.

You can employ `GROUP BY` with `HAVING` clauses to recognize duplicate records while letting you remove them according to minimum or maximum ID value conditions. This technique lets you select particular duplicates that you will remove manually instead of depending on automatic row numbering.

A preview of duplicate rows must be executed using `SELECT` before performing any delete operation. The protection of data loss requires taking a backup of the database and table before any operation.


---

Original Source: https://www.mindstick.com/forum/161178/how-to-delete-duplicate-rows-based-on-single-column-value-in-mssql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
