Environment: SharePoint 2016 OnPremise Farm
Issue: Error when adding content database to SQL Always on Availability group using the following PowerShell command
Add-DatabaseToAvailabilityGroup -AGName AGSP1 -DatabaseName SPContentDB -FileShare \\UTI01\AlwaysOnShare
Error: Add-DatabaseToAvailabilityGroup : Exclusive access could not be obtained because the database is in use.
RESTORE DATABASE is terminating abnormally.
Fix: Make sure the content database in the secondary database has been removed before executing the above PowerShell command.
Issue: Error when adding content database to SQL Always on Availability group using the following PowerShell command
Add-DatabaseToAvailabilityGroup -AGName AGSP1 -DatabaseName SPContentDB -FileShare \\UTI01\AlwaysOnShare
Error: Add-DatabaseToAvailabilityGroup : Exclusive access could not be obtained because the database is in use.
RESTORE DATABASE is terminating abnormally.
Fix: Make sure the content database in the secondary database has been removed before executing the above PowerShell command.