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
What is the difference between indexing and hashing?
What is purpose of normalization?
Is it important for a database administrator to understand the operating system and file access?
Define clusters?
What is nonclustered index with included columns ?
role of sql sever 2005 in database rather than any other database
How to convert numeric expression data types by assignment operations?
How can you start sql server in different modes?
Is BCNF better than 2NF & 3NF? Why?
Can you tell me some of the common replication dmv's and their use? : sql server replication
Explain sql server service broker?
How can I track the changes or identify the latest insert-update-delete from a table?
What is the syntax to execute the sys.dm_db_missing_index_details? : sql server database administration
How to add more data to the testing table in ms sql server?
Explain in details security in SQL azure?