1.备份数据库

backup database DbName to disk='D:\DbName.bak'

2、创建数据库:

create database DbName
on (name='DbName_Dev',filename='D:\DbName.mdf')
log on (name='DbName_Log', filename='D:\DbName.ldf')

如果需要还原数据库,create database DbName就够了,数据库设备名和文件路径在还原的时候指定。

3、查看备份文件存在哪些文件组:

restore filelistonly from disk='D:\DbName.bak'

以便在还原数据库的时候对各个文件组进行重定向。

4、还原数据库:

restore database DbName from disk='D:\DbName.bak' with
move 'DbName_Dev' to 'D:\DbName.mdf',
move 'DbName_Log' to 'D:\DbName.ldf',
replace

上面分别转移了数据设备、日志、全文目录。

Last modification:March 4th, 2019 at 09:40 am
If you think my article is useful to you, please feel free to appreciate