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 / gaurav sharma

SELECT DISTINCT * INTO Employee1 FROM Employee
DROP Table Employee
sp_rename 'Employee1','Employee'

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to declare a cursor with "declare ... Cursor" in ms sql server?

567


Explain the relational database management system (rdbms)?

524


What are basics of policy management?

608


Can another user execute your local temporary stored procedures?

539


Define synonym?

726






How to change the ownership of a schema in ms sql server?

563


What is create statement?

529


Can a stored procedure call itself or a recursive stored procedure? How many levels of sp nesting is possible?

581


What is a ddl statement?

511


How will you go about resolving deadlocks?

549


explain different types of cursors? : Sql server database administration

559


What is a with(nolock)?

575


What does truncate do?

531


how many type of indexing in database?

577


what is the system function to get the current user's user id? : Sql server database administration

555