--分离数据库
exec sp_detach_db 'DB_Lottery'
--附加数据库
exec sp_attach_db DB_Lottery,'D:\DB\DB_Lottery\DB_Lottery.mdf','D:\DB\DB_Lottery\DB_Lottery_log.ldf'
--备份数据文件
backup database DB_Lottery to disk='D:\data\DB_Lottery_back'
--备份日志文件
backup log DB_Lottery to disk='D:\data\DB_Lottery_Log_back'
--恢复备份数据库
restore database DB_Lottery from disk='D:\data\DB_Lottery_back' --(恢复的前提需要备份日志文件)
转载于:https://my.oschina.net/u/1426828/blog/277666