Wednesday, January 11, 2012

Deleting Duplicates comparing columns in SQL Server

Hi,
    Today let's see how to remove Duplicates row comparing Particular Columns. Following would be the SQL code that facilitates you to get job done.

  SELECT *
   FROM (
         SELECT col 1, "Your Coloum 1
                col 2, "Your Coloum 1
                col 3, "Your Coloum 1
                col 4, "Your Coloum 1
                col n, "Your Coloum n
               ROW_NUMBER() OVER
                               (
                               PARTITION BY [col 1(colum 1 that you need to delete duplicates )],
                                                        [col 2(colum 3 that you need to delete duplicates )],
                                                        [col n(colum n that you need to delete duplicates )],
                                      ORDER BY [col 1],[ col 2] DESC  or ASCS) AS RowCountNo
                                          FROM [dbo].[Table]
               ) AS X
         WHERE RowCountNo = 1

Thats all lol... :-)

SAP HANA Cloud Integration SAP : Part -01

What Is SAP HANA Cloud Integration? CPI-DS is a cloud-based data integration tool for batch & scheduled data integration between on-pr...