How to retrieve duplicate rows in a table?
How to delete the duplicate entries in a table?
Answer Posted / madhur/amrutha
select ROW_NUMBER() OVER (ORDER BY names ASC) AS ROWID, *
into #temp from emp
select * from #temp where ROWID not in(
select b.ROWID from
(
select ROW_NUMBER() OVER (ORDER BY names ASC) AS ROWID, *
from emp
except
SELECT ROW_NUMBER() OVER (ORDER BY names ASC) AS ROWID, *
FROM
(
select names , sal from emp
union
select distinct names,sal from emp) as a ) as b)
drop table #temp
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
How to query multiple tables jointly?
What are differences in between sql server 2012 and sql server 2016?
How can we solve concurrency problems?
What will be query used to get the list of triggers in a database?
What action plan is preferred if sql server is not responding?
Write a Select Query to display title for each group of records, which are collected with Compute Clause? Like titlefield column-A column-B ..... ..... ..... Sum ... titlefield column-A column-B ..... ..... ..... Sum ...
What language is sql server written in?
Does a full backup include transaction log?
What are four major operators that can be used to combine conditions on a where clause?
what is the maximum size of a row? : Sql server database administration
What is difference between equi join and natural join?
What do you understand by integration services in sql server?
How to execute a sql statement using odbc_exec()?
How to convert a table data in XML format in sql server?
You are designing a database for your human resources department in the employee table, there is a field for social security number, which cannot contain null values if no value is given, you want a value of unknown to be inserted in this field what is the best approach?