I have a table EMP in which the values will be like this

EmpId Ename Sal DeptId
11 Ram 10000 10
11 Ram 10000 10
22 Raj 20000 20
22 Raj 20000 20
33 Anil 15000 30
33 Anil 15000 30

I want to delete only duplicate Rows. After Delete I want
the output like this

EmpId Ename Sal DeptId
11 Ram 10000 10
22 Raj 20000 20
33 Anil 15000 30



Answers were Sorted based on User's Feedback



I have a table EMP in which the values will be like this EmpId Ename Sal DeptId 11 Ra..

Answer / shankar

Delete FROM EMP where EMPID in (Select max(EMPID) from EMP
Group by EMPID having Count(EMPID)>1)

Is This Answer Correct ?    0 Yes 1 No

I have a table EMP in which the values will be like this EmpId Ename Sal DeptId 11 Ra..

Answer / samadhan

use distinct keywor in sql query

Is This Answer Correct ?    1 Yes 4 No

I have a table EMP in which the values will be like this EmpId Ename Sal DeptId 11 Ra..

Answer / ashim kumar pal

SET rowcount 3

delete distinct * from table

set rowcount 0

select * from table

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL Server Interview Questions

What do you understand by a view?

0 Answers  


How to add an address record into adventureworkslt?

0 Answers  


What are SSL and TSL protocols?

0 Answers   Wipro,


What is meant by datasource?

0 Answers  


What is split brain scenario in DB mirroring?

1 Answers  






Explain how many normalization forms?

0 Answers  


How to see the event list of an existing trigger using sys.trigger_events?

0 Answers  


1. How to fetch all the duplicate records from the table. 2. How to fetch the second highest salary from the table.

12 Answers   Accenture,


How to delete exactly duplicate records from a table?

0 Answers  


what is the purpose of creating view is sql server 2000

13 Answers   Wipro,


What do you understand by intent locks?

0 Answers  


What is the use of placing primary key and foreign key constrains on columns.

4 Answers   Value Labs,


Categories