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 / guest
WITH T1 AS (
SELECT ROW_NUMBER () OVER ( PARTITION BY EmpId ORDER BY
EmpId) AS RNUM,EmpId FROM EMP)
delete
FROM T1 WHERE RNUM > 1
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the order in which the sql query is executed?
How to create a store procedure with encryption?
What are the advantages of paper records?
What are system databases into sql server (2005/2008)?
What are different types of table joins?
How can you list all the table constraints in a database?
How can I change procedure name in sql server?
Explain the difference between delete,drop and truncate in SQL Server?
How adventureworkslt tables are related?
How will you hide an attribute? : sql server analysis services, ssas
What is difference between order by and group by?
What command would you use to add a column to a table in sql server?
What are differences in between sql server 2012 and sql server 2016?
What is difference between views and tables?
What are the disadvantages of using querystrings to send data from one page to another?