ALTER DATABASE SET HADR (Transact-SQL)
This topic contains the ALTER DATABASE syntax for setting AlwaysOn Availability Groups options on a secondary database. Only one SET HADR option is permitted per ALTER DATABASE statement. These options are supported only on secondary replicas.
When a secondary database is joined to an availability group, the local secondary replica changes the state of that secondary database from RESTORING to ONLINE. If a secondary database is removed from the availability group, it is set back to the RESTORING state by the local secondary replica. This allows you to apply subsequent log backups from the primary database to that secondary database.
The following example joins the secondary database, AccountsDb1, to the local secondary replica of the AccountsAG availability group.
ALTER DATABASE AccountsDb1 SET HADR AVAILABILITY GROUP = AccountsAG;
Note |
|---|
To see this Transact-SQL statement used in context, see Create an Availability Group (Transact-SQL). |
Note
Important