HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Rename Availability Group and AG script

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
scriptgroupavailabilityandrename

Problem

I have two questions for you guys. I really appreciate your help.

1.- Is there a way to rename an Availability Group?

2.- Is there a way to get the T-SQL statements in order to re create a Availability Group in case that I need to drop it and create it again?

If there's information that you want me to share, please let me know and I will provide it.

Solution

-
Once created an Availability Group (AG) cannot be renamed, although the databases within the AG can be renamed. You'd have to re-create it.
See here for the options for ALTERing an AG: https://msdn.microsoft.com/en-us/library/ff878601.aspx

-
When creating the AG using the GUI (wizard), once all the steps are completed you will see a 'Script' button which gives the option to generate a script of those steps to a new window.
You can then either save the script for later and quit the GUI, or just "finish" the wizard to actually create the AG. (The script will stay in the window)
It's a good idea to keep the script in case it needs to be re-created later (e.g. if you want to rename the AG...)

It doesn't seem to be currently possible to "Script As..." an AG in the way you would for a table or stored procedure for example.

You could also write the CREATE AVAILABILITY GROUP statement from scratch using the MSDN boilerplate code as a starting point (https://msdn.microsoft.com/en-us/library/ff878399.aspx) but that is likely to be very cumbersome and error-prone compared to using the GUI which will check you've got everything right before it lets you proceed!

Context

StackExchange Database Administrators Q#114158, answer score: 5

Revisions (0)

No revisions yet.