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
Answer Posted / vijay
I have tried this query in my PC.Very simply I was able to
remove all duplicate rows.
Please try below query it will work out.
SELECT DISTINCT*FROM EMP(TableName);
You will get below table
EmpId Ename Sal DeptId
11 Ram 10000 10
22 Raj 20000 20
33 Anil 15000 30
Suppose if you have different ENAME but you want only
selected ENAME without duplicate records.
Where We can use below query.
SELECT DISTINCT*FROM EMP WHERE ENAME IN('RAM','RAJ','ANIL');
Please correct me if I am wrong.
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is blocking?
What is the full meaning of dml?
What is merge statement?
What are the steps you can take to avoid “deadlocks”?
how many triggers you can have on a table? : Sql server database administration
How to truncate the log in sql server 2012? : sql server database administration
What is a cache in ssrs?
Suggest a method of joining two tables.
Explain what are magic tables in sql server?
Explain the various types of concurrency problem?
Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting is possible?
What is public role in sql server?
What is store procedure? How do they work?
List the various tools available for performance tuning?
How to change the name of a database user?