adspace


How can delete duplicate records in cte in sql server?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How to enter binary string literals in ms sql server?

1256


How can you append an identity column to a temporary table?

1078


what is the difference between openrowset and openquery?

1208


What are the properties of the transaction?

1084


How can I check that whether automatic statistic update is enabled or not?

1121


Can one drop a column from a table?

1098


What is sql or structured query language?

1235


How do I find the sql server version?

1114


How to convert numeric expression data types using the cast() function?

1157


How to rebuild the master database?

1175


How to connect php with different port numbers?

1197


What is the difference between upgrade and migration in sql server?

1193


How can we solve concurrency problems?

1130


List the ways in which dynamic sql can be executed?

1099


What is an indexed view?

1030