About 3,370,000 results
Open links in new tab
  1. SQL Query to Delete Duplicate Rows - GeeksforGeeks

    Apr 14, 2025 · In this article, we will explain the process of deleting duplicate rows from a SQL table step-by-step, using SQL Server, with examples and outputs. We’ll cover techniques using GROUP BY , CTE , and more, incorporating best practices …

  2. sql - Delete duplicate rows keeping the first row - Stack Overflow

    Jul 3, 2017 · To delete the duplicate rows from the table in SQL Server, you follow these steps: Find duplicate rows using GROUP BY clause or ROW_NUMBER() function. Use DELETE statement to remove the duplicate rows.

  3. Different ways to SQL delete duplicate rows from a SQL Table - SQL

    Aug 30, 2019 · SQL delete duplicate Rows using Common Table Expressions (CTE) We can use Common Table Expressions commonly known as CTE to remove duplicate rows in SQL Server. It is available starting from SQL Server 2005. We use a SQL ROW_NUMBER function, and it adds a unique sequential row number for the row.

  4. sql - How can I delete duplicate rows in a table - Stack Overflow

    Nov 25, 2015 · Delete the duplicates from the original table: DELETE t1 FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2 Insert the original rows: INSERT t1 SELECT * FROM holddups btw and for completeness: In Oracle there is a hidden field you could use (rowid): DELETE FROM our_table WHERE rowid not in (SELECT MIN(rowid) FROM …

  5. sql server - How can I remove duplicate rows? - Stack Overflow

    To Fetch Duplicate Rows: SELECT name, email, COUNT(*) FROM users GROUP BY name, email HAVING COUNT(*) > 1 To Delete the Duplicate Rows: DELETE users WHERE rowid NOT IN (SELECT MIN(rowid) FROM users GROUP BY name, email);

  6. Remove duplicate rows from a table in SQL Server - SQL Server

    Jan 10, 2025 · This article provides a script that you can use to remove duplicate rows from a table in Microsoft SQL Server. There are two common methods that you can use to delete duplicate records from a SQL Server table. For demonstration, start by creating a sample table and data: INSERT INTO original_table values (1)

  7. SQL delete duplicate rows

    Here’s a guide on how to delete duplicate rows in SQL: Identifying Duplicate Rows. Before deleting duplicate rows, you need to identify them. You can use the GROUP BY clause along with the HAVING clause to find rows where certain columns have duplicate values.

  8. 3 Ways to Remove Duplicate Rows from Query Results in SQL

    Dec 6, 2023 · The most common way to remove duplicate rows from our query results is to use the DISTINCT clause. The simplest way to use this is with the DISTINCT keyword at the start of the SELECT list. Suppose we have a table like this:

  9. How to Remove Duplicate Rows in SQL - Baeldung

    Jul 30, 2024 · In this tutorial, we’ll learn how to find duplicate rows in our SQL tables and remove them correctly. First, we’ll look at a database management system (DBMS) agnostic approach to find and remove duplicates. Then, we’ll explore techniques specific …

  10. Find and Remove Duplicate Rows from a SQL Server Table

    Jul 20, 2021 · Removing duplicate values from table with a unique index is a bit easier than removing the rows from a table without it. First of all, we need to find duplicates. There are many different ways to do that. Let’s investigate and compare some common ways.

Refresh