windows server定时任务

windows server定时任务_第1张图片

windows server定时任务_第2张图片

windows server定时任务_第3张图片

windows server定时任务_第4张图片

backup.bat

sqlcmd -S MESSQL01 -i D:\DBBackup\backup.sql

 bakup.SQL

DECLARE @preferredReplica INT
  
SET @preferredReplica = (SELECT
[master].sys.Fn_hadr_backup_is_preferred_replica('TJ_MES'))
  
IF ( @preferredReplica = 1 )
  BEGIN
DECLARE @FileName varchar(1000)
SELECT @FileName = (SELECT 'D:\DBBackup\Files\TJ_MES' + convert(varchar(500), GetDate(),112) + '.bak')
BACKUP DATABASE TJ_MES TO DISK=@FileName
SELECT @FileName = (SELECT 'D:\DBBackup\Files\U4DMMES' + convert(varchar(500), GetDate(),112) + '.bak')
BACKUP DATABASE U4DMMES TO DISK=@FileName
SELECT @FileName = (SELECT 'D:\DBBackup\Files\OCEXFN_Eng' + convert(varchar(500), GetDate(),112) + '.bak')
BACKUP DATABASE OCEXFN_Eng TO DISK=@FileName
SELECT @FileName = (SELECT 'D:\DBBackup\Files\OCEXFN_sys' + convert(varchar(500), GetDate(),112) + '.bak')
BACKUP DATABASE OCEXFN_sys TO DISK=@FileName
SELECT @FileName = (SELECT 'D:\DBBackup\Files\OCEXFN_tmp' + convert(varchar(500), GetDate(),112) + '.bak')
BACKUP DATABASE OCEXFN_tmp TO DISK=@FileName
SELECT @FileName = (SELECT 'D:\DBBackup\Files\TEST_DB' + convert(varchar(500), GetDate(),112) + '.bak')
BACKUP DATABASE TEST_DB TO DISK=@FileName
END

你可能感兴趣的:(数据库,SqlServer,部署,数据库)