sqlcmd -S MESSQL01 -i D:\DBBackup\backup.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), Ge