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
Explain the xml support sql server extends?
Tell me what are the advantages of using stored procedures?
What purpose does the model database server?
What is Command line parameters in PLSQL.?
How to change the password of a login name in ms sql server?
A trigger can reference objects outside the current database? State true or false.
What to perform pattern match with the like operator?
What are the new scripting capabilities of ssms? : sql server management studio
What is importing utility?
What is the process of normalization?
what is the information that can be stored inside a bit column? : Sql server database administration
Define right outer join?
What are the new features introduced in SQL Server 2000 (or the latest release of SQL Server at the time of your interview)? What changed between the previous version of SQL Server and the current version?
What program is used to store the data source file?
What are null values in ms sql server?