How To delete duplicate record from a particular table?
Answer Posted / kala suresh
--BY USING A TEMP TABLE TO DELETE DUPLICATE ROWS OF A TABLE
WITH OUT A PRIMARY KEY COLUMN OR AN IDENTITY COLUMN
SELECT Name, age, ROW_NUMBER() OVER(ORDER BY age) AS
'RowNumber' into #temp1 FROM RowNumber
delete from #temp1 where rownumber not in(select
max(rownumber) from #temp1 group by name,age)
delete from rownumber
select * from #temp1 into rownumber
drop table #temp1
--BY USING AN IDENTITY COLUMN TO DELETE DUPLICATE ROWS OF A
--TABLE WITH OUT A PRIMARY KEY COLUMN
delete from rownumber where id not in(select min(id) from
rownumber group by name,age)
select * from rownumber
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What are the advantages of sql azure?
How many database files are there in sql server 2000?what are they?
What are the character string functions supported by sql server 2005?
How to modify the underlying query of an existing view?
What is the purpose of indexing?
What are the properties of the relational tables?
1. Tell me your daily activities 2. If sql server installation fails at time installation what will do 3. Where does the sql server installation log details are stored 4. After the installation what will you do for memory configuration 5. What is the difference between SQL max maximum memory and AWE memory 6. How will you configure AWE memory 7. How will setup an email alert for the backup job 8. After the SQL installation what are the jobs will you configure 9. What does –g mean in the sql startup parameter 10. What is the difference between Bulked log and Full recovery model 11. What is the difference between mirroring and log shipping 12. What are the steps to be followed before in-place up gradation 13. After installing the patch the sql server does not start and application team tells to rollback the changes .In this scenario what will you do
How to select an exiting database using mssql_select_db()?
What is scan table/view and seek table/view when its occurs? : sql server database administration
Name 3 ways to get an accurate count of the number of records in a table?
What is coalesce in sql server?
What is Service Broker in sql server 2012?
What is abstracting periodical?
What is normalization? Explain different forms of normalization?
What is sql server 2000 work load governor?