備份數據庫,例如:
backup database northwind 
   to disk = 'c:/northwind.bak'
還原數據庫,例如:
--返回由備份集內包含的數據庫和日志文件列表組成的結果集
restore filelistonly 
   from disk = 'c:/northwind.bak'
--還原由backup備份的數據庫
restore database northwind
   from disk = 'c:/northwind.bak' 
--指定還原后的數據庫物理文件名稱及路徑
restore database testdb 
   from disk = 'c:/northwind.bak'
   with 
   move 'northwind' to 'c:/test/testdb.mdf',
   move 'northwind_log' to 'c:/test/testdb.ldf'
   move 'logical_file_name' to 'operating_system_file_name'
指定應將給定的 logical_file_name 移到 operating_system_file_name。
默認情況下,logical_file_name 將還原到其原始位置。如果使用 restore 
語句將數據庫復制到相同或不同的服務器上,則可能需要使用 move 選項重
新定位數據庫文件以避免與現有文件沖突。可以在不同的 move 語句中指定
數據庫內的每個邏輯文件。 
--強制還原,加上replace參數,則在現有數據庫基礎上強制還原。
restore database testdb 
   from disk = 'c:/northwind.bak'
   with replace,
   move 'northwind' to 'c:/test/testdb.mdf',
   move 'northwind_log' to 'c:/test/testdb.ldf' 
新聞熱點
疑難解答