Is it possible to delete duplicate rows in a table without
using a temporary table ?
Answer Posted / brajesh
DECLARE temp CURSOR FOR SELECT id FROM cars1 c GROUP BY
c.id,c.name,c.year
DECLARE @id int
OPEN temp
FETCH next FROM temp
INTO @id
WHILE @@FETCH_STATUS=0
BEGIN
IF EXISTS (SELECT id FROM cars1 GROUP BY cars1.id
HAVING count(*)>1 AND id=@id)
DELETE TOP(SELECT count(*)-1 FROM cars1 WHERE
cars1.id=@id )FROM cars1 WHERE id=@id
FETCH next FROM temp
INTO @id
END
CLOSE temp
DEALLOCATE temp
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Do you know what are acid properties of transaction?
Do you know the cursor types?
Does sql server 2016 have ssms?
What do you mean by authentication modes in sql server?
Does windows server 2016 come with sql server?
How sql server enhances scalability of the database system?
What is the difference between the 2 operating modes of database mirroring?
what is dbcc? : Sql server database administration
How can you list all the columns in a database?
You want to use a perspective in an mdx query. How do you select the perspective?
Name some of the open source software that you can use in alternative to SSR?
What do you mean by an execution plan? Why is it used? How would you view it?
What is entity data services?
How to create prepared statements using odbc_prepare()?
How to perform backup for certificates in sql server? : sql server security