Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Fix a database corruption?

Status
Not open for further replies.

cybercat2001

Programmer
Mar 14, 2001
2
US
Hi All,

I am working in a test environment where I need to corrupt a database for test purpose/R&D.
After corrupting the database, I ran the DBCC CHECKDB (pubs, repair_fast) and then DBCC
CHECKDB (pubs, repair_rebuild) commands. But it's not fixing the corrupt database.

My question is why DBCC is not fixing the corrupted Database? Is that a limitation of DBCC
or is there any other way/command or tool to fix the corrupted database other then restoring
from the previously backed up file.

The following are the steps that I followed to corrupt the database:
I used the following script (available in the script section of to corrupt
the pubs database.

sp_configure allow, 1
go
reconfigure with override
go
update sysindexes set FirstIAM = 1234
where id = OBJECT_ID('roysched')
go
sp_configure allow, 0
go
reconfigure with override
go

Then I did a select * from roysched. I got the error:
Server: Msg 5180, Level 22, State 1, Line 1
Could not open FCB for invalid file ID 53764 in database 'pubs'. Table or database may be
corrupted.

The pubs database got corrupted. Now, I want to fix this error. So I set the pubs database
to single user mode and ran the DBCC command :
DBCC CHECKDB (pubs, repair_fast) that doesn't help so I ran the DBCC CHECKDB (pubs,
repair_rebuild) command.

I got big DBCC output. I doesn't seems to fix the pubs database. When I did a select * from
roysched again it gave the same corruption error.

I would appreciate any help in this issue.

Thanks
Sri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top