分享你我的心得.
共乘一片美好网络.

SQLServer如何备份,按照日期自动备份

SqlServer自动作业备份 1、打开SQL Server Management Studio 2、启动SQL Server代理 3、点击作业->新建作业 4、”常规”中输入作业的名称 5、新建步骤,类型选T-

SqlServer自动作业备份

1、打开SQL Server Management Studio

2、启动SQL Server代理

3、点击作业->新建作业

4、”常规”中输入作业的名称

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

复制代码代码如下:
DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ‘:’ , ‘.’)
set @strPath = ‘D:\bak\’ + ‘databasename’+@strPath + ‘.bak’
BACKUP DATABASE [databasename] TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT
例如:
DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ‘:’ , ‘.’)
set @strPath = ‘D:\bak\’ + ‘fx’+@strPath + ‘.bak’
BACKUP DATABASE [fx] TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT

(D:\bak\改为自己的备份路径,databasename修改为想备份的数据库的名称)

6、添加计划,设置频率,时间等。

赞(0)
未经允许不得转载:小叶白龙博客 » SQLServer如何备份,按照日期自动备份
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址