Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!watmath!xenitec!timk From: timk@xenitec.uucp (Tim Kuehn) Newsgroups: comp.databases Subject: Re: Deleting duplicate records Keywords: unique key, deleteing duplicate records Message-ID: <1989Jul17.165249.26554@xenitec.uucp> Date: 17 Jul 89 16:52:49 GMT Reply-To: timk@egvideo.UUCP (Tim Kuehn) Organization: Xenitec Consulting Services, Kitchener, ON Lines: 53 englandr@phoenix.Princeton.EDU (Scott Englander) writes: >I'd like to delete duplicate records in a FoxBase file. ... Previous attempt deleted ... >But there must be a better way to do this using the unique index, since >only the first record with a given value of the index field is indexed. >-- > > - Scott try this: Definintions: ------------- dborig: the original database dbunique: the database with duplicate records removed ndxuniq: the index file on the key with only unique values of the key : the key value you are indexing on Program: -------- use dborig copy structure to dbuniq select 0 use dbunique select dborig index on to ndxuniq unique set index to ndxuniq go top do while .not. eof() select dbuniq append blank replace dbuniq->field1 with dborig->field1,; dbuniq->field2 with dborig->field2,; dbuniq->field3 with dborig->field3,; dbuniq->field4 with dborig->field4 <...etc...> select dborig skip enddo hope this helps! +-----------------------------------------------------------------------------+ |Timothy D. Kuehn timk@xenitec | |TDK Consulting Services !watmath!xenitec!timk | |871 Victoria St. North, Suite 217A | |Kitchener, Ontario, Canada N2B 3S4 (519)-741-3623 | |DOS/Xenix - SW/HW. uC, uP, DBMS. Satisfaction Gauranteed| +-----------------------------------------------------------------------------+