【IT168 服务器学院】详细步骤:
a. Change the database context to Master and allow updates to system tables:
Use Master
Go
sp_configure ''allow updates'', 1
reconfigure with override
Go
b. Set the database in Emergency (bypass recovery) mode:
select * from sysdatabases where name = ''<db_name>''
-- note the value of the status column for later use
begin tran
update sysdatabases set status = 32768 where name = ''<db_name>''
-- Verify one row is updated before committing
commit tran
c. Stop and restart SQL server.
d. The syntax for DBCC REBUILD_LOG is as follows:
DBCC REBUILD_LOG(''<db_name>'',''<log_filename>'')
e. Set the database in single-user mode and run DBCC CHECKDB to validate physical consistency:
-- Put database in single user mode and run CHECKDB.
sp_dboption ''<db_name>'', ''single user'', ''true''
DBCC CHECKDB(''<db_name>'')
Go
-- Address any errors reported by CHECKDB.
-- Take the database out of single user mode.
sp_dboption ''<db_name>'', ''single user'', ''false''
f. Turn off the updates to system tables by using:
sp_configure ''allow updates'', 0
reconfigure with override
Go