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 differentiate between a having clause and a where clause?
What is a select query statement in ms sql server?
What is rolap and its advantage? : sql server analysis services, ssas
What are the triggers in sql?
What are the approximate numeric data types?
Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?
What do you understand by integration services in sql server?
What does top operator do?
How to truncate the log in sql server 2012? : sql server database administration
How to insert multiple rows with one insert statement in ms sql server?
What is subquery in sql?
Give an example of SQL injection attack ?
What is the purpose of the model database?
What are logical database components? : SQL Server Architecture
What is application role in sql server database security? : sql server security