Subject | Re: [firebird-support] removing duplicate records |
---|---|
Author | Alexandre Benson Smith |
Post date | 2004-07-01T19:58:09Z |
Hi Alan,
alan davies wrote:
DELETE FROM
Supplier s1
WHERE
RecordID <> (SELECT Min(RecordID) FROM Supplier s2 WHERE s2.Weigh_Code = s1.Weigh_Code)
you could create an index on Weigh_Code, I think will speed it up.
Another way:
Mark the records that will be kept and delete the others.
like this:
Alter table Supplier add Foo char(1);
commit;
Update
Supplier s1
set
foo = '1'
where
RecordID = (SELECT Min(RecordID) FROM Supplier s2 WHERE s2.Weigh_Code = s1.Weigh_Code);
Delete from Supplier where Foo Is Null;
After you are sure that only the records you want are on the table...
commit;
Alter table Supplier drop Foo;
commit;
HTH
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
alan davies wrote:
>Arno - Thanks for the advice, but this does not work. I get the sqlTry this one:
>hourglass and windows task manager shows cpu at 100% with ibexpert not
>responding. All I can do is end the task (this is the same on another
>machine trying ibconsole) because the system is unresponsive.
>
>Alan J Davies
>Aldis
>Tel: +44(0)1926 842069
>Fax: +44(0)1926 843755
>
>
>
>
DELETE FROM
Supplier s1
WHERE
RecordID <> (SELECT Min(RecordID) FROM Supplier s2 WHERE s2.Weigh_Code = s1.Weigh_Code)
you could create an index on Weigh_Code, I think will speed it up.
Another way:
Mark the records that will be kept and delete the others.
like this:
Alter table Supplier add Foo char(1);
commit;
Update
Supplier s1
set
foo = '1'
where
RecordID = (SELECT Min(RecordID) FROM Supplier s2 WHERE s2.Weigh_Code = s1.Weigh_Code);
Delete from Supplier where Foo Is Null;
After you are sure that only the records you want are on the table...
commit;
Alter table Supplier drop Foo;
commit;
HTH
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br