Re: sql question
Posted in 1997
Topics: SQL Development & Query Writing
What database are you using? If it is DB2 UDB, you can do something manually like db2 +c "declare c1 cursor for select * from tablename for update" db2 +c "open c1" db2 +c "fetch c1" db2 +c "fetch c1" db2 +c "delete from tablename where current of c1" db2 +c "fetch c1" db2 +c "delete from tablename where current of c1" .... db2 commit The +c turns off the auto commit option (otherwise your cursor would not stay open long enough to fetch). Your select statement should be more specific than "select *" so that you select a series of duplicate records. After ignoring the first record. you can fetch and delete the duplicates. There are more elegant ways to do this and I do not recommended this approach as a production level item. I assume you do not have any end user tools, you do not wish to write a small program and this is a small one time only cleanup. Suggest you back up the table before you try anything. Regards, Bob ministry of education wrote: > I have a table with multiple exact duplicate rows.No indexes. How do I > delete all duplicate rows to get a single occurrence for each row? > > Thanx.