Deleting certain records using SQL

Dave31

Registered User.
Local time
Today, 17:57
Joined
Oct 11, 2006
Messages
68
Hi there, i have a master reset to delete all the data in the database. Although, as there is a username and password entry to get into the admin module, i wish for one entry in the table participantTable to not get deleted (to save one password/username so its possible to log into the admin module after the reset). The code below will delete everything, how can i change it so it keeps the first record in the table, and then deletes all the other records after.

Code:
DoCmd.RunSQL "DELETE * from participantTable"

Thanks in advance
 
How do you identify the first record? You can use criteria to in a delete query.
Code:
DELETE tblData.*
FROM tblData 
WHERE [PK]<>1;
This example deletes all the records from tblData except records where [PK] = 1. In this example, [PK] is an autonumber so only 1 record will not be deleted.
 

Users who are viewing this thread

Back
Top Bottom