Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Explain the ways to controlling cursor behavior?

968


What is the purpose of optimization?

1064


What does it mean to manipulate data?

1056


How to enter date and time literals in ms sql server?

1070


What is a scheduled job or what is a scheduled task?

1012


Why use stored procedures in sql server?

1064


why would you use sql agent? : Sql server database administration

1271


What are sp_configure commands and set commands?

1082


How do I shrink an ldf file?

1040


Explain few examples of stored procedure over triggers?

1122


How can sql injection be stopped? : sql server security

1107


Where are full-text indexes stored?

1040


You want to implement the one-to-many relationship while designing tables. How would you do it?

1001


What is subquery in sql?

1131


explain different types of constraints? : Sql server database administration

1004