Results 1 to 3 of 3

Thread: corrupted table

  1. #1
    Join Date
    Jan 2003
    Posts
    67

    Unanswered: corrupted table

    I have a table that I am now assuming is corrupted. There are records in the table, however not all records are available in a basic select.

    So I want rebuild the index first and if that does not work I want to rebuild the table. Are there any risk in dropping the indexes and recreating them? How about the auto increment field in the table can that be reloaded?

    Thanks in advance for your help.

  2. #2
    Join Date
    May 2003
    Posts
    12
    create a new table exactly the same as the corrupted one. BCP out the old data and bcp it into the new table - then rebuild your indexes, procs, triggers e.t.c on the new table - if all is fine - rename it to the old name.

  3. #3
    Join Date
    Jun 2003
    Posts
    15

    Re: corrupted table

    Originally posted by timmoser
    I have a table that I am now assuming is corrupted. There are records in the table, however not all records are available in a basic select.

    So I want rebuild the index first and if that does not work I want to rebuild the table. Are there any risk in dropping the indexes and recreating them? How about the auto increment field in the table can that be reloaded?

    Thanks in advance for your help.
    I assume that when you say not all records are available in a select that this means you get an error when trying to do a basic select (I assume this is a table scan select). If this is the case then bcp will fail also. It is possible that the index is healthy and you have some corrupted page pointers in the data page chain. If the index is non-clustered you can see if this is healthy by forcing a read of the index for the whole table (ie select count(*) from table (index indexname)) -- check my syntax!. If this runs without error then the index is healthy. If it's healthy, you can create a new table using "select * into newtable from badtable (index indexname)". Then drop the bad table and rename the new table to the old table name. Of course any triggers and such would have to be recreated as well.

    If the index is non-clustered and unhealthy, try just dropping and recreating the index.

    Beyond this, there are some very tricky and risky things to do to recover so it would be better if you have a good backup.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •