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 / soorai ganesh
Hey dude, If u use SQLSERVER 2005 This will help u.
;WITH tmpEmp AS
(
SELECT ROW_NUMBER() OVER(PARTITION BY EmpID ORDER BY EmpID)
AS RowNumber, * FROM EMP
)
DELETE FROM tmpEmp WHERE RowNumber> 1
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
How to stop log file growing too big?
What is the default fill factor value?
you have couple of stored procedures that depend on a table you dropped the table and recreated it what do you have to do to reestablish those stored procedure dependencies?
How to automatically create a log when an exception is being received into SQL Server?
how to avoid cursors? : Sql server database administration
What is mscorsvw.exe - process - microsoft .net framework ngen?
What is implicit mode in sql server?
What is difference between delete & truncate commands?
Explain full-text indexing?
How to create a user to access a database in ms sql server using "create user" statements?
Explain concepts of analysis services?
Explain cdc and sql injection?
What is "scheduled jobs" or "scheduled tasks"?
Why union all is faster than union?
What are the advantages of sql stored procedure?