Adding an availability database to an Availability Group
In this recipe, we will add an availability database to an Availability Group.
Getting ready
Before we proceed with this recipe, ensure that you have already created the availability group in the primary instance.
The prerequisites for adding an availability database, as documented on MSDN, are as follows:
- You must be connected to the server instance that hosts the primary replica
- The database must reside on the server instance that hosts the primary replica and comply with the prerequisites and restrictions for availability databases
How to do it...
Perform the following steps to add an availability database to an existing availability group:
- Open PowerShell ISE as an administrator.
- Add the following script and run it:
Import-Module SQLPS -DisableNameChecking $AGName = "SQLAG" $dbName = "QueryWorksDB" $secondaryList = @("SQL02", "SQL03") $cred = Get-Credential foreach ($secondary in $secondaryList...