IF EXISTS (SELECT name FROM master.dbo.sysdevices WHERE name = N'mx_hr_backup')
EXEC sp_dropdevice 'mx_hr_backup' // 删除原备份设备
GO
DECLARE @filename VARCHAR(255)
DECLARE @now AS DATETIME
SELECT @now = GETDATE()
SELECT @filename = 'C:\Program Files\Wizit Software\Wiz_HR\mx_hr_' + //备份文件主文件名
CAST(DATEPART(yyyy, @now) AS VARCHAR) +
CAST(DATEPART(mm, @now) AS VARCHAR) +
CAST(DATEPART(dd, @now) AS VARCHAR) +
CAST(DATEPART(hh, @now) AS VARCHAR) +
CAST(DATEPART(mi, @now) AS VARCHAR) +
CAST(DATEPART(ss, @now) AS VARCHAR) +
CAST(DATEPART(ms, @now) AS VARCHAR)
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'xm_hr')
BEGIN
EXEC sp_addumpdevice 'disk', 'mx_hr_backup', @filename // 添加备份设备
BACKUP DATABASE xm_hr TO mx_hr_backup WITH INIT // 备份数据库
END
GO
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073