使用SQL Server的作业进行数据库备份

点击 管理/sql server代理/作业
新建作业:
常规选项卡里,"名称"填写"定时备份数据库","启用"前面选"对勾","以本地服务器为目标",
 "分类"选择"数据库服务",
步骤选项卡里,新建步骤,步骤名:备份数据库;类型:Transact-SQL脚本(TSQL);

 数据库:要备份的数据库
 命令(可同时备份多个数据库):

DECLARE
 @FileName VARCHAR(200),
 @CurrentTime VARCHAR(50)

SET @CurrentTime = CONVERT(CHAR(8),GETDATE(),112) + CAST(DATEPART(hh, GETDATE()) AS VARCHAR) + CAST(DATEPART(mi, GETDATE()) AS VARCHAR)

SET @FileName = 'D:\CE_BPS\DataBaseBackup\DPC_TEXT' + @CurrentTime
BACKUP DATABASE [CE_BPS_DPC_TEXT] TO DISK = @FileName WITH NOINIT, NOUNLOAD, NAME = N'CE_BPS_DPC_TEXT-备份', NOSKIP, STATS = 10, NOFORMAT

SET @FileName = 'D:\CE_BPS\DataBaseBackup\DPC_IMAGE' + @CurrentTime
BACKUP DATABASE [CE_BPS_DPC_IMAGE] TO DISK = @FileName WITH NOINIT, NOUNLOAD, NAME = N'CE_BPS_DPC_IMAGE-备份', NOSKIP, STATS = 10,NOFORMAT


备份所有用户数据库
Code
posted @ 2008-11-03 11:30  一沙  阅读(1194)  评论(0编辑  收藏  举报