Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting repetitive rows from a table 1

Status
Not open for further replies.

Sminair

Programmer
Apr 21, 2005
8
IN
Pls give me the query of removing repititive rows from my table.
Can it be done only with the help of a cursor???
 
I assume you mean duplicate rows? If so, can you give details on what column(s) will be duplicated and how you want to determine which row to keep (eg earliest date etc).

--James
 
yes i mean duplicate rows. My table consists of rows in which all the records are duplicated. Actually i transferred data from Symix(ERP) to my SQL table and got duplicated records.
For eg (pls dont mind if the fields are not in order)
Empo Firsname Lastname Age Salary Address
I1 smitha nair 20 10000 Bglr
I1 smitha nair 20 10000 Bglr
I2 Ajith T S 30 30000 Delhi
I2 Ajith TS 30 30000 Delhi
I2 Ajith TS 30 30000 Delhi
I3 James Anderson 25 20000 New York
I3 James Anderson 25 20000 New York

if this is the table which is having duplicate rows..
I want to retain only on record each.
My table has thousands of records and most of them are repating some 4-5 times. If I just want to retain top 1 record for each employee pls tell me what am i supposed to do.

Thks for the reply.
 
If rows are absolutely identical, then simply do SELECT DISTINCT * INTO temptable trick.

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top