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 / smitha

;with empctc(empid,ename,sal,deptid,ranking)
as
(Select empid,ename,sal,deptid,ranking=Dense_rank() over (
partition by empid,ename,sal,deptid order by NEWID() asc)
from emp
)
delete * from empctc where ranking>1

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name 3 ways to get an accurate count of the number of records in a table?

1086


What is indexing and its types?

1056


how many bits ip address consist of? : Sql server database administration

943


Explain different types of index?

1101


How to define and use table alias names in ms sql server?

1208


What are sub reports and how to create them?

144


What is spid in sql server profiler?

1168


how to overcome kernel isssues

1687


difference between Clustered index and non clustered index ?

1035


How to configure odbc dsn with different port numbers?

1152


What happens if date-only values are provided as date and time literals?

1077


What are the operating modes in which database mirroring runs?

1137


Why we need to use secondry database file? though, we can do same work using primary database file also.

7008


What is the difference between ‘having’ clause and a ‘where’ clause?

1086


Please explain that what are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture

1021