delete records not selected

  • Thread starter Thread starter James Bertino
  • Start date Start date
J

James Bertino

I know what records to keep so how do I DELETE the records that don't match
my SELECT statement?
Thanks in advance,
Jay
 
Hi,
Normally, you'd have something like this:
Delete yourTable Where id Not In (your selectstatement here)

HTH
Dan Artuso, MVP
 
Thanks Dan,
In your statement you mention "id", is this a field? If so I don't want to
do that, takes to long. So, I 've been thinking that I could create two
recordsets one of the table and one of the sql statement. Then just run a
..MoveNext to compare the two. When it finds a match move to next when they
don't match delete from Table and movenext. Do you think that's fast?
However if "id" isn't a field could you discribe your code?
Jay
 
Hi,
First, an SQL statement is almost always faster than opening a recordset and
then
doing your processing.
id would be your primary key, which would also be included in your select
statement.

If you care to post more info (tabel names, field names etc) we can get the
exact syntax.

HTH
Dan Artuso, MVP
 
Back
Top