How can delete duplicate records in cte in sql server?



How can delete duplicate records in cte in sql server?..

Answer / Shyam Lal Kushwaha

To delete duplicate records from a CTE (Common Table Expression) in SQL Server, you can use the ROW_NUMBER() window function along with DELETE statement. Here is an example:nnWITH cte AS (n SELECT *, ROW_NUMBER() OVER(ORDER BY YourColumn) as rnn FROM YourTablen)nDELETE cte WHERE rn > 1;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Explain primary key, foreign key and unique key?

1 Answers  


I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration

1 Answers  


what are the new features of sql server 2005?

8 Answers   HP, Keane India Ltd,


optimization techinques

1 Answers   Wipro,


Which command is used for user defined error messages?

1 Answers  


What are the types of dml?

1 Answers  


What is join query?

1 Answers  


what are file groups?

3 Answers   Evalueserve,


Why functions are used in sql server?

1 Answers  


What is raid and what are different types of raid levels?

1 Answers  


Where the sql logs gets stored?

1 Answers  


What is transaction server auto commit?

1 Answers  


Categories