Find duplicate rows in SQL Server by multiple conditions

My fields are

ID | Name | StartTime | EndTime | Date | Description

I am looking for a way to select all rows with the same entries in all fields except for the ID.

  • Connecting to MS SQLServer from Qt Linux application
  • SQL server average when first value 0
  • Accessing an SQL Server stored procedure (containing no SELECT statement) from Excel VBA, ideally without using Excel Data Connections?
  • My last column isn't getting populated
  • Hierarchical Table and Query in SQL Server
  • SQL query to combine two rows into one as result
  • I am not that familiar with SQL so I tried this approach but there is only one field relevant not (as in my case) five.

    My first idea was to try something like:

    SELECT *
    FROM Table
    order by Name, Date, StartTime, EndTime, Description
    

    if I would look through all entries I would at least find the duplicates but that is definitely not the best way to solve the problem.

    4 Solutions collect form web for “Find duplicate rows in SQL Server by multiple conditions”

    This should do what you need:

    select Name, Date, StartTime, EndTime, Description
    from   table
    group by Name, Date, StartTime, EndTime, Description
    having count(*) > 1
    

    This query should work for you:

    SELECT ID, Name, StartTime, EndTime, Date, Description
    FROM (
        SELECT 
            ROW_NUMBER() OVER (PARTITION BY ID ORDER BY ID, Name, Date, StartTime, EndTime, Description) AS 'IndexNr'
            , ID
            , Name
            , StartTime
            , EndTime
            , Date
            , Description
        FROM Table) AS ResultSet
    WHERE ResultSet.IndexNr > 1
    

    Try below query.

    SELECT     Name, Date, StartTime, EndTime, Description
    FROM    Table
    GROUP BY Name, Date, StartTime, EndTime, Description
    HAVING      (COUNT(*) > 1)
    

    You can try this:-

    SELECT *
    FROM TAB_NAME
    HAVING COUNT(CONCAT(Name, StartTime, EndTime, Date, Description)) > 1
    

    This will give you all the rows that are repeated except than the ID.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.