码迷,mamicode.com
首页 > 数据库 > 详细

backup/restore database

时间:2019-01-30 12:45:38      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:mdf   div   pos   master   sele   code   where   tor   font   

backup database t-sql

1 BACKUP DATABASE [store] TO  DISK = ND:\sql_back\store_backup_2019_01_30_102306_4000360.bak WITH NOFORMAT, NOINIT,  NAME = Nstore_backup_2019_01_30_102306_4000360, SKIP, REWIND, NOUNLOAD,  STATS = 10
2 GO
3 declare @backupSetId as int
4 select @backupSetId = position from msdb..backupset where database_name=Nstore and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=Nstore )
5 if @backupSetId is null begin raiserror(N验证失败。找不到数据库“store”的备份信息。, 16, 1) end
6 RESTORE VERIFYONLY FROM  DISK = ND:\sql_back\store_backup_2019_01_30_102306_4000360.bak WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND

 

 

restore database

1 USE [master]
2 BACKUP LOG [store] TO  DISK = ND:\sql_back\store_LogBackup_2019-01-30_10-44-29.bak WITH NOFORMAT, NOINIT,  NAME = Nstore_LogBackup_2019-01-30_10-44-29, NOSKIP, NOREWIND, NOUNLOAD,  NORECOVERY ,  STATS = 5
3 RESTORE DATABASE [store] FROM  DISK = NE:\mssql\store.bak WITH  FILE = 1,  MOVE Nstore TO ND:\install\store.mdf,  MOVE Nstore_log TO ND:\sql_data\store_log.LDF,  NOUNLOAD,  STATS = 5
4 
5 GO

 

backup/restore database

标签:mdf   div   pos   master   sele   code   where   tor   font   

原文地址:https://www.cnblogs.com/neoo9901/p/10337012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!