MSSQL数据库还原置疑的处理方法

发布时间:2013/2/12     点击数:4389

步骤1:

创建一个新的数据库,命名为原来数据库的名字。

步骤2:

停止SQL Server

步骤3:

把老数据库的MDF文件替换新数据库的相应的MDF文件,并把LDF文件删除。

步骤4:

重新启动SQL Server服务,然后运行如下命令:

Use Master

Go

sp_configure 'allow updates', 1

reconfigure with override

Go

begin tran

update sysdatabases set status = 32768 where name = 'db_name'

--Verify one row is updated before committing

commit tran

步骤5:

停止SQL然后重新启动SQL Server服务,然后运行如下命令:

DBCC TRACEON(3604)

DBCC REBUILD_LOG('db_name','c:\mssql7\data\dbxxx_3.ldf')

Go

步骤6:

停止SQL然后重新启动SQL Server服务,然后运行:

use master

update sysdatabases set status = 8 where name = 'db_name'

Go

sp_configue 'allow updates', 0

reconfigure with override

Go

步骤7:

运行dbcc checkdb(db_name) 检查数据库的完整性

注:都要替换成真实的数据库名字。