Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE master;
- DECLARE @last_role TINYINT;
- SET @last_role = (
- SELECT TOP 1 [replica_role]
- FROM [dbo].[replica_role]
- );
- DECLARE @current_role TINYINT;
- SET @current_role = (
- SELECT ROLE
- FROM sys.dm_hadr_availability_replica_states
- WHERE is_local = 1
- );
- IF (@last_role = 2 AND @current_role = 1)
- BEGIN
- USE SSISDB;
- OPEN MASTER KEY DECRYPTION BY PASSWORD = 'x'
- ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY
- END
- USE master;
- UPDATE dbo.[replica_role] SET [replica_role] = @current_role;
- The target database ('SSISDB') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement