To join a secondary database to an availability group
Connect to the server instance that hosts the secondary replica.
Use the SET HADR clause of the ALTER DATABASE statement, as follows:
ALTER DATABASE database_name SET HADR AVAILABILITY GROUP = group_name
where database_name is the name of a database to be joined and group_name is the name of the availability group.
The following example joins the secondary database, Db1, to the local secondary replica of the MyAG availability group.
ALTER DATABASE Db1 SET HADR AVAILABILITY GROUP = MyAG;