標籤:sql server copy database
SQL Server 2008如何copy database:
方法一:使用Microsoft SQL Server Management Studio中的Copy Database Wizard來輔助完成。(很容易失敗)
方法二:採取Backup/Restore的方式(推薦)
a.備份資料庫到磁碟
BACKUP DATABASE Source_Database TO DISK = 'D:\Backup\Source_Database.bak'WITH FORMAT;
b.查看備份檔案的邏輯檔案
RESTORE FILELISTONLYFROM DISK = 'D:\Backup\Source_Database.bak';
c.建立目標資料庫
CREATE DATABASE Target_Database;
d.從磁碟複製資料庫
/*利用bak恢複資料庫,強制還原(REPLACE)STATS = 10 每完成10%顯示一條記錄Source_Database和Source_Database_log是上面D:\Backup\Source_Database.bak裡的邏輯檔案*/RESTORE DATABASE Target_DatabaseFROM DISK='D:\Backup\Source_Database.bak' WITH MOVE 'Source_Database' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Target_Database.mdf',MOVE 'Source_Database_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Target_Database_log.ldf',STATS = 10,REPLACE
SQL Server 2008如何copy database