We’re in Maryland as well and have a SQL Server question

Hello CCD,

I’m glad to see that there are local IT companies in Maryland with SQL Server expertise.  My colleagues and I were wondering how to get rid of duplicate rows in a SQL Server table.  Do you know about this?

Tom in Maryland

One thought on “We’re in Maryland as well and have a SQL Server question

  1. Hello Tom,
    Yes, glad to hear from neighbors in Maryland! Our company is located in Gaithersburg, Maryland. Where are you located in Maryland?

    Regarding your question, I am including some sample code that you can use to delete duplicate rows in SQL Server. Are you in charge of the database management for your company? Let me know if you have any difficulties with the code.

    DELETE Table1
    FROM Table1
    LEFT OUTER JOIN (
    SELECT MIN(RowId) as RowId, Column1, Column2, Column3
    FROM Table1
    GROUP BY Column1, Column2, Column3
    ) as KeepRows ON
    Table1.RowId = KeepRows.RowId
    WHERE
    KeepRows.RowId IS NULL

Comments are closed.