if 3 duplicate records, by keeping one original and one
duplicate record, and how to delete remaining 2 duplicates in
sql server 2008



if 3 duplicate records, by keeping one original and one duplicate record, and how to delete remai..

Answer / Bijendra Singh

In SQL Server 2008, you can use the ROW_NUMBER() function to keep one original and one duplicate record, and then delete the remaining two duplicates. Here's an example:nn```sqlnWITH CTE AS (n SELECT *, ROW_NUMBER() OVER(PARTITION BY [column1], [column2] ORDER BY [column1]) as rownumn FROM your_tablen)nDELETE FROM CTE WHERE rownum > 2;n``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

What is Big-O notation?

1 Answers  


Hi guyes, I have cleared 2 technical rounds with cts for liferay and java techonologies, i have client round next week, please tell me how to prepare for this what questions i should be ready to face?

1 Answers  


technical interview questions and process

0 Answers   Ariba,


how do find the user exit for selected feild whatis the process and can u plz explain it

1 Answers  


What is a must for multitasking? a) Process preemption b) Paging c) Virtual memory d) None of the above

9 Answers   InterGraph,


Given three sides of a triangle. Write the Program to determine whether the triangle is : 1) Invalid 2) Right Angled 3) Isoscales 4) Equilateral 5) Not Special An Isoscales right angled triangle should be taken as a Right Angled Triangle

3 Answers   FFC, Goldman Sachs, Student,


is possible to delete specific data in a row by using of sql query?

0 Answers   HCL,


when we use mantis? how learn mantis?

1 Answers  


what is woransient key word? how it is used in java

1 Answers   Convergys,


Data structure used to impliment a menu:

0 Answers   Verifone,


what is difference between input parameter and output parameter.

1 Answers   NIIT,


1) How can u create the table?

1 Answers   IBM,


Categories