Applies to: SQL Server 2016 (13.x) and later versions
Restores the authenticated connection between a local database enabled for Stretch and the remote database.
Stretch Database is deprecated in SQL Server 2022 (16.x). This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
sp_rda_reauthorize_db [ @credential = ] credential , [ @with_copy = ] with_copy [ , [ @azure_servername = ] azure_servername , [ @azure_databasename = ] azure_databasename ] [ ; ]
[ @credential = ] N'credential'
The database scoped credential associated with the local Stretch-enabled database. @credential is sysname.
[ @with_copy = ] with_copy
Specifies whether to make a copy of the remote data and connect to the copy (recommended). @with_copy is bit.
[ @azure_servername = ] azure_servername
Specifies the name of the Azure server that contains the remote data. @azure_servername is sysname.
[ @azure_databasename = ] azure_databasename
Specifies the name of the Azure database that contains the remote data. @azure_databasename is sysname.
Return code values
0 (success) or
> 0 (failure).
Requires db_owner permissions.
When you run sys.sp_rda_reauthorize_db (Transact-SQL) to reconnect to the remote Azure database, this operation automatically resets the query mode to
LOCAL_AND_REMOTE, which is the default behavior for Stretch Database. That is, queries return results from both local and remote data.
The following example restores the authenticated connection between a local database enabled for Stretch and the remote database. It makes a copy of the remote data (recommended) and connects to the new copy.
DECLARE @credentialName NVARCHAR(128); SET @credentialName = N'<existing_database_scoped_credential_name>'; EXEC sp_rda_reauthorize_db @credential = @credentialName, @with_copy = 1;