Hello all,
After such a long time , I would like to post some another blog which might be helpful to the one who works in SQL.
Sometimes we might need to delete the particular row from a table in SQL Database.
While working someone might mistakenly insert the duplicate same data multiple times within a table that might contains a huge amount of data and after populating that table .He/she wants to delete that duplicate data inserted from a table.
So, for this we might drop and recreate the table or truncate the table and insert again. But, if it is a large table then it would be better to find the duplicate row within a table and delete duplicate one which helps in time consumption and server utilization too.
In order to obtain this , we can simple used a simple query as
WITH newtbl as(SELECT *, 'row number'=ROW_NUMBER() over (order by FirstName) FROM CustomerList) DELETE FROM newtbl WHERE [row number]=2 --where CustomerList is a user table having dublicate record.
This is the tested script for Test Database where CustomerList table have duplicate records which needs to be delete.
This is just a simple example and looks simple but it might help for the one who indeed needs such a solution.
Regards,
Anil Maharjan