作者:月舞B的啊 | 来源:互联网 | 2017-05-12 14:55
简单的SQL Server备份脚本代码
一般的情况下我们会选用SQL Server自带的数据库维护计划来定义备份.
但有些时候,有的机器数据库维护计划不能成功实现备份.
错误原因可能不尽相同, 这时我们可以用简单的SQL Server备份脚本来做备份.
生成简单的SQL Server备份脚本的SQL语句:
use master
select 'backup database '+name+' to disk=''F:\sqlserver_backup\'+name+'.bak'' with init' from sysdatabases
-------------------------------------------------------------------------------------------------
backup database master to disk='F:\sqlserver_backup\master.bak' with init
backup database model to disk='F:\sqlserver_backup\model.bak' with init
backup database msdb to disk='F:\sqlserver_backup\msdb.bak' with init
backup database db_app1 to disk='F:\sqlserver_backup\db_app1.bak' with init
backup database db_app2 to disk=F:\sqlserver_backup\db_app2.bak' with init