T-SQL 备份数据库

2024-01-08 16:51:36
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 

END

文章来源:https://blog.csdn.net/lybwwp/article/details/135459460
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。