How to delete corrupted records only in a table ?

smmurugansmmurugan Member Posts: 33
Hi friends,

We had a crash of NAV native DB when we were trying to expand the DB by 10 GB. (was expanded from 45 GB to 55 GB)

Somehow we were able to open the database working fine for the end user. Since then we are not able to take navision inbuilt back up of the DB saying DB is corrupted. After close analysis we found the table corrupted also the records corrupted. We are able access other records except corrupted records.

I am planning to clean table as below:

1. Export all the records in a text file which are not corrupted
2. Delete the all the records in the table.
3. Import the exported data which are clean

My concern is this table is containing millions of records, Exporting / deleting / reimporting takes time and down time will be more.

Is there any way I can delete only the corrupted records on the table directly or through code.

I tried as below :

1. In the table filter the records. Afftected record entry no. range is 41..81 . I even tried 35..85.

2. Same I tried through code also.

In Both the scenarios got the message 'corrupted'.

Can any one suggest best way to minimise down time ?

Thanks

Murugan

Comments

  • ShedmanShedman Member Posts: 194
    In the same situation, I did the following:
    - Create a new table, as a copy of the corrupted table
    - Copy the records from the corrupted table to the new table, from the first until (not including) the first corrupted record
    - Copy the records from the corrupted table to the new table, from the last up until (not including) the last corrupted record
    - DELETEALL from the corrupted table. Don't fire the trigger!
    - I removed and recreated the object, but that may be optional
    - Copy all the records from the new table back to the once corrupted table

    In my case I had 3 tables with only 1 corrupted record each, and was able to restore all the non-corrupted records this way. I don't know if it is possible to recover records between corrupted records. It wouldn't surprise me if you can't.
  • krikikriki Member, Moderator Posts: 9,110
    But before doing anything, make a copy of the database files and try anything on those. If it doesn't work, you can make a new copy to retry.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.