| ||||||
|
| Contact_ID | Contact_Name | Contact_Address | Contact_City | Contact_State | Contact_Phone |
|---|---|---|---|---|---|
| 1 | Joseph Dean | 148 Kirwans Landing Lane | Chester | MD | 410 929-9399 |
| #Deleted | #Deleted | #Deleted | #Deleted | #Deleted | #Deleted |
| 3 | Billy Bob | 12 Main Street | Somewhere | XX | 555-1212 |
It is likely that you will have thousands of records before the corrupted record and either none or a few record after the corrupted record.
Whenever you try to use this table you'll get some error message. You will not be able to make a copy of the table nor will you be able to export it to Excel. And you won't be able to use Delete Record to simply delete the bad record.
Here is the simple 4-step process we use the recover all records except the corrupted record:
1) Create a make table query using the Select Top 1 predicate query:
SELECT TOP 1 M_Contacts.Contact_ID, M_Contacts.Contact_Name,
M_Contacts.Contact_Address, M_Contacts.Contact_City, M_Contacts.Contact_State,
M_Contacts.Contact_Phone INTO M_Contacts_Fixed
FROM M_Contacts;
Note that we are building a new table called M_Contacts_Fixed.
2) Open the newly created table (M_Contacts_Fixed) and delete all records. Note the datatype of the Contact_ID field. If it was an autonumber field in the old contact table then it should be an autonumber field in this new contact table. Our goal will be to retain the original autonumbered field values.
3) Change the query to an Append Query and add a criteria to the Contact_ID field so that you select all records above the corrupted record. In our example we will select all records <=1. Also remove the Select Top 1 predicate:
INSERT INTO M_Contacts_Fixed
SELECT
FROM M_Contacts
WHERE M_Contacts.Contact_ID<=1;
4) Next we will append all the good records after the corrupted record. Note that you can skip this step if the corrupted record is the last record in the table:
INSERT INTO M_Contacts_Fixed
SELECT
FROM M_Contacts
WHERE M_Contacts.Contact_ID>=3;
At this point all the good records will be in the new table (M_Contacts_Fixed ). All you need to do is delete or rename the corrupted table and rename the new table appropriately.
|
A Blue Claw Database Design Template: Marina Management Reservations Software |
|
A Blue Claw Database Design Article: Repair Corrupted Access Table |
|
|