Sql Server定时自动备份数据库

首先启动数据库“SQL Server代理”,启动方式分两种

一、SQL Servers 配置管理器,将SQL Server 2005 服务中的SQL Server代理(SQL Server Agent)启用。

二、右击我的电脑——管理——服务和应用程序——服务,找到SQL Server代理(SQL Server Agent),进行启用。 

SQL Server代理启动后—>右键点击作业->新建作业 —>"常规"中输入作业的名称

—>新建步骤,类型选T-SQL,在下面的命令中输入下面语句

DECLARE @strPath varchar(200)

set  @strPath = convert(varchar(20),getdate(),120)

set @strPath = REPLACE(@strPath, ':' , '.')
--设置路径
set @strPath = 'D:\bakDB\' + 'databasename'+@strPath + '.bak'
BACKUP DATABASE [databasename] TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT
(D:\bakDB\改为自己的备份路径,databasename修改为想备份的数据库的名称)添加计划,设置频率,时间等看自己情况设置

搞定!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

原文地址:https://www.cnblogs.com/yshj/p/2881617.html