Sql-Server
還原數據庫時出錯(Windows 7 測試環境)
我有一個 Windows 7 作業系統作為測試環境。我安裝了帶有兩個實例的 SQL Server EE,分別命名為測試和生產。我從測試實例的 AdventureWorks 數據庫中進行了完整備份,並嘗試將其恢復到生產實例中:
RESTORE DATABASE [testikanta] FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008TESTI\MSSQL\Backup\AdventureWorks.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO
我收到一條錯誤消息:
Msg 3634, Level 16, State 1, Line 1 The operating system returned the error '32(failed to retrieve text for this error. Reason: 15105)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008TESTI\MSSQL\DATA\AdventureWorks_Data.mdf'. Msg 3156, Level 16, State 8, Line 1 File 'AdventureWorks_Data' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008TESTI\MSSQL\DATA\AdventureWorks_Data.mdf'. Use WITH MOVE to identify a valid location for the file. Msg 3634, Level 16, State 1, Line 1 The operating system returned the error '32(failed to retrieve text for this error. Reason: 15105)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008TESTI\MSSQL\DATA\AdventureWorks_Log.ldf'. Msg 3156, Level 16, State 8, Line 1 File 'AdventureWorks_Log' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008TESTI\MSSQL\DATA\AdventureWorks_Log.ldf'. Use WITH MOVE to identify a valid location for the file. Msg 3119, Level 16, State 1, Line 1 Problems were identified while planning for the RESTORE statement. Previous messages provide details. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally.
問題出在哪裡?我以本地電腦管理員的身份執行這些實例(SQL Server 服務使用相同的帳戶執行)。
‘32(未能為此錯誤檢索文本。原因:15105)’
根據一些搜尋,這似乎是 SQL Server 未正確報告作業系統(Win32 API)錯誤的方式。
錯誤 32 是 ERROR_SHARING_VIOLATION “該程序無法訪問該文件,因為它正被另一個程序使用。”
其他東西打開了文件,這可能是其他一些連接,或者甚至是用來進行恢復的連接打開了 AdventureWorks。
就我而言,這是一件非常愚蠢的事情。經過多次檢查後,我沒有意識到 SAS 的開始日期在“未來”是不正確的。在墨西哥,我們使用 dd/mm/yyyy,問題是擷取的日期是“mm/dd/yyyy”,而該日期是將來的日期。更新該日期後,恢復工作。