About 536,000 results
Open links in new tab
  1. 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.

  2. SQL Query to Delete Duplicate Rows - GeeksforGeeks

    Apr 14, 2025 · Duplicate rows in a SQL table can lead to data inconsistencies and performance issues, making it crucial to identify and remove them effectively. 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.

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

    To Delete the Duplicate Rows: DELETE users WHERE rowid NOT IN (SELECT MIN(rowid) FROM users GROUP BY name, email);

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

    Aug 30, 2019 · In this article, we explored the process of SQL delete duplicate rows using various ways such as T-SQL, CTE, and SSIS package. You can use the method in which you feel comfortable. However, I would suggest not to implement these procedures and package on the production data directly.

  5. 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: Result: This table contains two dogs named Bark, and coincidentally, they are both aged 10.

  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

    Deleting duplicate rows in a database table is a common task in SQL, and it’s important for maintaining data integrity. Duplicate rows can occur for various reasons, such as data entry errors or system glitches. Here’s a guide on how to delete …

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

    Nov 25, 2015 · First find the duplicate rows: If there are only few, you can delete them manually: The value of "rowcount" should be n-1 times the number of duplicates. In this example there are 2 dulpicates, therefore rowcount is 1. If you get several duplicate rows, you have to do this for every unique primary key.

  9. SQL Remove Duplicates: Methods and Best Practices - DataCamp

    Oct 29, 2024 · There are different methods of removing duplicates while retrieving records in SQL. Each method depends on the DBMS, such as SQL Server, MySQL, and PostgreSQL. In this section, we will look at the methods of removing duplicates while highlighting any special consideration for each database.

  10. How to Remove Duplicate Records in SQL - Database Star

    Jun 9, 2023 · In any case, identifying and removing duplicates is possible in SQL. There are several ways to do it. I’ll explain each of these methods. We’ll see how it can work on Oracle, SQL Server, MySQL, and PostgreSQL. The sample of data has 1,220 records in a …