标签00标签001标签02标签03

说明:

  • SSIS Package遵循某种特定策略执行;
  • 在执行策略前,需要保持一直打开状态;

策略

image.png

AlwaysON

  1. IF SERVERPROPERTY ('IsHadrEnabled') = 1
  2. BEGIN
  3. DECLARE @RoleDesc NVARCHAR(60)
  4. SELECT @RoleDesc = a.role_desc
  5. FROM sys.dm_hadr_availability_replica_states AS a
  6. JOIN sys.availability_replicas AS rp ON rp.replica_id = a.replica_id AND rp.replica_server_name = SERVERPROPERTY ('ServerName')
  7. JOIN sys.availability_groups AS ag ON ag.group_id = rp.group_id
  8. JOIN sys.availability_databases_cluster AS clusters ON clusters.group_id = ag.group_id AND clusters.database_name = 'CustomDB'
  9. IF @RoleDesc <> 'PRIMARY'
  10. BEGIN
  11. RAISERROR('Not Primary AG', 16, 1)
  12. END
  13. END

  • 本文作者:GeekPower - Felix Sun
  • 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!