标签00标签001标签02标签03
说明:
- SSIS Package遵循某种特定策略执行;
- 在执行策略前,需要保持一直打开状态;
策略
AlwaysON
IF SERVERPROPERTY ('IsHadrEnabled') = 1
BEGIN
DECLARE @RoleDesc NVARCHAR(60)
SELECT @RoleDesc = a.role_desc
FROM sys.dm_hadr_availability_replica_states AS a
JOIN sys.availability_replicas AS rp ON rp.replica_id = a.replica_id AND rp.replica_server_name = SERVERPROPERTY ('ServerName')
JOIN sys.availability_groups AS ag ON ag.group_id = rp.group_id
JOIN sys.availability_databases_cluster AS clusters ON clusters.group_id = ag.group_id AND clusters.database_name = 'CustomDB'
IF @RoleDesc <> 'PRIMARY'
BEGIN
RAISERROR('Not Primary AG', 16, 1)
END
END
- 本文作者:GeekPower - Felix Sun
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!