adspace
How to delete duplicate rows from table except one?
Answer Posted / Ajay Kumar Sharma
"To delete duplicate rows from a table while keeping only one, you can use the ROW_NUMBER() window function. Here's an example:nnWITH CTE AS (n SELECT *, ROW_NUMBER() OVER(PARTITION BY column1, column2 ORDER BY column3) rnn FROM yourTablen)nDELETE CTE WHERE rn > 1".
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are different types of constraints?
What is the difference between upgrade and migration in sql server?
Where can you add custom error messages to sql server?
You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?
Can one drop a column from a table?
Explain system functions or built-in functions? What are different types of system functions?
How can you append an identity column to a temporary table?
Can you index views?
What are the different subsets of sql?
How to remove duplicate rows from table except one?
Does view occupy space?
When should you use an instead of trigger?
If any stored procedure is encrypted, then can we see its definition in activity monitor?
How can I check that whether automatic statistic update is enabled or not?
What is an indexed view?