文章来源:https://www.toymoban.com/news/detail-819671.html
文章来源地址https://www.toymoban.com/news/detail-819671.html
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
到了这里,关于windows server定时任务的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!