Home > Database > Mysql Tutorial > SQL Server 2008如何复制数据库

SQL Server 2008如何复制数据库

WBOY
Release: 2016-06-07 16:45:29
Original
1518 people have browsed it

SQL Server 2008如何复制数据库: 方法一:使用Microsoft SQL Server Management Studio中的Copy Database Wizard来辅助完成。(

SQL Server 2008如何复制数据库:

方法一:使用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 FILELISTONLY
FROM 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_Database
FROM 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

本文永久更新链接地址:

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template