Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500
Output should be
A 200
B 300
C 400
D 500
Answer Posted / samba shiva reddy . m
delclare @temp(empname varchar(50),sal int)
select * into @temp
FROM employee
GROUP BY empname, salary
HAVING count(*) > 1
delete from employee
select * into employee from @temp as temp
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is the difference between DATETIME2 and DATETIME?
How will you know when statistics on a table are obsolete?
What are the reporting services components?
Where the sql logs gets stored? : sql server database administration
Can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible?
How to modify an existing stored procedure in ms sql server?
Define Joins?
how do you determine the Load performance of any query in sql server {example how do u determine performance of a select stmnt which returns Dynamically many no of records ... some times 100,1000,10000 etc., }
What is a hint?
What is "scheduled jobs" or "scheduled tasks"?
Is it possible in sql table to have more than one foreign key?
Define constraints and give an example of their use?
What is clr ddl trigger?
Do you know what is a with(nolock)?
How would you use user_constraints table in DB?