sys.sp_rda_reauthorize_db (Transact-SQL)

APPLIES TO: yesSQL Server (starting with 2016) noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

Restores the authenticated connection between a local database enabled for Stretch and the remote database.

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
sp_rda_reauthorize_db @credential = @credential, @with_copy = @with_copy [ , @azure_servername = @azure_servername, @azure_databasename = @azure_databasename ]  

Arguments

@credential = *@credential*
Is the database scoped credential associated with the local Stretch-enabled database.

@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)

Permissions

Requires db_owner permissions.

Remarks

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.

Example

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;  
  

See Also

sys.sp_rda_deauthorize_db (Transact-SQL)
Stretch Database