Click here to Skip to main content
15,913,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a data table it contains some Duplicate row . in Is_duplicate column of datatable i wants to add flag Y.



Suggest me best way.

Can we also filter on combination of Some column.
Posted

 
Share this answer
 
Or you use:
ROW_NUMBER() function
SQL
SELECT *, ROW_NUMBER() OVER (PARTITION BY col1, col2, col3, col4 ORDER BY (SELECT 0)) AS DuplicateRowNumber
FROM table
where DuplicateRowNumber > 1


or you create a CTE object:

SQL
WITH cte AS
(SELECT *, ROW_NUMBER() OVER (PARTITION BY col1, col2, col3, col4 ORDER BY (SELECT 0)) AS DuplicateRowNumber
    FROM table
)
UPDATE cte WHERE DuplicateRowNumber > 1
 
Share this answer
 
v2
Comments
Sudheer Kumar Tiwari 15-Oct-13 2:50am    
I want to handle in Data Table of ADO.net not in database

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900