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 triggers and its types?
What is the full form of ddl?
Where do we use trace frag?
Explain about the command-line tool SQLCMD?
How can we get count of the number of records in a table?
What are the five major components of a dbms?
How can you hide the sql server instances?
Where are sql server usernames and passwords stored in the sql server?
How can we delete a table in sql server?
What is difference between index and primary key?
Do you know data definition language, data control language and data manipulation language?
What is data set in report?
What is dynamic cursor in SQL SERVER?
Explain cross join or cartesian product in sql?
Where actually sql azure database is hosted?