1. 程式人生 > >SQL Server2000在只有主庫mdf檔案下的恢復(轉)

SQL Server2000在只有主庫mdf檔案下的恢復(轉)

SQL Server2000在只有主庫.mdf(如Test.mdf)檔案下的恢復:

1、新增一Test資料庫;

2、斷開MSServer(cmd-->net stop mssqlserver);
3、用原來的mdf檔案替換新的mdf檔案;
4、設定資料庫允許直接作業系統表:
    use master
    go

    sp_configure 'allow updates',1
    go 

    reconfigure with override
    go
5、設定test為緊急修復模式:
    update sysdatabases set status=-32768 where dbid=DB_ID('test')
6、重建資料庫日誌檔案:
    dbcc rebuild_log('test','C:\Program Files\Microsoft SQL Server\MSSQL\Data\test_log.ldf')
7、驗證資料庫一致性:
    dbcc checkdb('test')
8、設定資料庫為正常狀態:
    sp_dboption 'test','dbo use only','false'
9、恢復“允許對系統目錄直接修改”項:
    sp_configure 'allow updates',0
    go 

    reconfigure with override
    go
10、設定資料庫為多使用者:ALTER DATABASE 資料庫名 SET MULTI_USER