adspace


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


Please Help Members By Posting Answers For Below Questions

what is the difference between openrowset and openquery?

1197


Does view occupy space?

1021


How raid can influence database performance?

1118


What is the primary use of the model database?

1151


What is in place upgrade in sql server?

1127


Can sql servers link to other servers like oracle?

919


What is acid mean in sql server?

1247


How do I find query history in sql server?

1025


How do I start sql server 2017?

1016


How to convert character strings into numeric values?

1191


what is spatial nonclustered index

1059


What is normalization and what are the advantages of it?

1057


Why use identity in sql server?

1202


You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?

1215


Why should you use or avoid select * statements?

1111