USE master -- (Cant sit in the database whilst its being restored!)GOALTER DATABASE MyDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATEGO-- Restore Full BackupRESTORE DATABASE MyDatabase FROM DISK = x:MSSQLBACKUPMyBackupFilename_Full.BAK WITH REPLACE, NORECOVERY, -- Use if more T/Logs to recover-- RECOVERY, -- Use if NO more T/Logs to recover STATS = , -- Show progress (every %) MOVE MyDatabase_Data TO x:MSSQLDATAMyDatabase.mdf, MOVE MyDatabase_Log TO x:MSSQLDATAMyDatabase.ldfGO-- Optional restore Differential BackupRESTORE DATABASE MyDatabase FROM DISK = x:MSSQLBACKUPMyDatabase_Diff.BAK WITH-- RECOVERY -- Use if NO more file to recover NORECOVERY -- Use if there are T/Logs to recoverGO-- Optional restore Transaction Log BackupRESTORE DATABASE MyDatabase FROM DISK = x:MSSQLBACKUPMyDatabase_yyyymmdd_hhmm_Trans.BAK WITH-- RECOVERY -- Use if NO more T/Logs to recover NORECOVERY -- Use if more T/Logs to recoverGO-- Set the database ready for use (after all backups have been restored)RESTORE DATABASE MyDatabase RECOVERYGO-- Rename logical names (only needed if restoring from a backup for a Different database):ALTER DATABASE MyDatabase MODIFY FILE (NAME = OrigDatabase_Data, NEWNAME = MyDatabase_data)GOALTER DATABASE MyDatabase MODIFY FILE (NAME = OrigDatabase_Log, NEWNAME = MyDatabase_log)GO
推荐整理分享如何恢复数据库备份到一个已存在的正在使用的数据库上(如何恢复数据库删除的文件),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:如何恢复数据库文件,如何恢复数据库文件,如何恢复数据库备份文件,如何恢复数据库删除的文件,如何恢复数据库备份,如何恢复数据库备份文件,如何恢复数据库备份,如何恢复数据库备份,内容如对您有帮助,希望把文章链接给更多的朋友!
设定sql server定期自动备份数据库 企业管理器中的Tools,DatabaseMaintenancePlanner,可以设置数据库的定期自动备份计划。并通过启动SqlserverAgent来自动运行备份计划。具体步骤如下:1、打开
xp_cmdshell开启与关闭 xp_cmdshell可以让系统管理员以操作系统命令行解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出,是一个功能非常强大的扩展存贮过程
更改SQL Server更改当前数据库的所有者:sp_changedbowner sp_change_users_login更改当前数据库中SQLServer用户与MicrosoftSQLServer登录之间的关系。语法sp_change_users_login[@Action=]'action'[,[@UserNamePattern=]'user'][,[@loginName=]'login'