當資料庫缺少了交易記錄檔時 (以下步驟皆有完成實測)
1.在 SQL 2000 時請利用附加資料庫的方式重新Create 交易記錄檔
2.在 SQL 2005 是亦是利用附加資料庫的方式但在附加時要將對話框的交易檔路 徑刪除即可
3.若在SQL 2000無法完成附加資料庫時可利用以下步驟完成交易記錄檔建立
A.在SQL Server Enterprise Manager裏面先建立資料庫如(test)。
B.停掉資料庫伺服器。
C.將資料庫的日誌檔test_log.ldf刪除,用要恢復的資料庫mdf檔蓋掉剛才建立的資料庫資料檔案test_data.mdf。
D.啟動資料庫伺服器。這時候不能對此資料庫進行任何操作。
E.設置資料庫允許直接作業系統表。可以使用如下語句來實現。
use master
go
sp_configure 'allow updates',1
go
reconfigure with override
go
F.設置test為緊急修復模式
update sysdatabases set status=-32768 where dbid=DB_ID('test')
G.重建資料庫日誌檔
dbcc rebuild_log('test','C:\Program Files\Microsoft SQL Server\MSSQL\Data\test_log.ldf')
此時請確認無人在使用資料庫包括SQL Server Enterprise Manager
I.設置資料庫為正常狀態
sp_dboption 'test','dbo use only','false'
J.將步驟E中設置的“允許對系統目錄直接修改”一項恢復。sp_configure 'allow updates',0
go
reconfigure with override
go
J.重新啟動SQL SERVER