Specifies a redirected publisher for an existing publisher/database pair. If the publisher database belongs to an Always On Availability Group, the redirected publisher is the availability group listener name associated with the availability group.
sp_redirect_publisher [ @original_publisher = ] 'original_publisher', [ @publisher_db = ] 'database_name' [ , [ @redirected_publisher = ] 'new_publisher' ]
[ @original_publisher = ] 'original_publisher'
The name of the instance of SQL Server that originally published the database. original_publisher is sysname, with no default.
[ @publisher_db = ] 'publisher_db'
The name of the database being published. publisher_db is sysname, with no default.
[ @redirected_publisher = ] 'redirected_publisher'
The availability group listener name associated with the availability group that will be the new publisher. redirected_publisher is sysname, with no default. When the availability group listener is configured to non-default port, specify the port number along with listener name, such as
Return Code Values
0 (success) or 1 (failure)
sp_redirect_publisher is used to allow a replication publisher to be redirected to the current primary of an Always On availability group by associating the publisher/database pair with an availability group's listener. Execute sp_redirect_publisher after the AG listener has been configured for the availability group that contains the published database.
If the publication database at the original publisher is removed from an availability group at the primary replica, execute sp_redirect_publisher without specifying a value for the @redirected_publisher parameter to remove the redirection for the publisher/database pair. For more information about redirecting the publisher when, see Maintaining an AlwaysOn Publication Database (SQL Server).
Caller must either be a member of the sysadmin fixed server role, the db_owner fixed database role for the distribution database, or a member of a publication access list for a defined publication associated with the publisher database.