gebeurtenis
31 mrt, 23 - 2 apr, 23
De grootste SQL-, Fabric- en Power BI-leerevenement. 31 maart – 2 april. Gebruik code FABINSIDER om $ 400 te besparen.
Zorg dat u zich vandaag nog registreertDeze browser wordt niet meer ondersteund.
Upgrade naar Microsoft Edge om te profiteren van de nieuwste functies, beveiligingsupdates en technische ondersteuning.
Applies to:
SQL Server
Azure SQL Managed Instance
Adds a new agent job used to schedule synchronization of a push subscription to a merge publication. This stored procedure is executed at the Publisher on the publication database.
Belangrijk
When configuring a Publisher with a remote Distributor, the values supplied for all parameters, including @job_login and @job_password, are sent to the Distributor as plain text. You should encrypt the connection between the Publisher and its remote Distributor before executing this stored procedure. For more information, see Configure SQL Server Database Engine for encrypting connections.
Transact-SQL syntax conventions
Notitie
Microsoft Entra ID was previously known as Azure Active Directory (Azure AD).
sp_addmergepushsubscription_agent
[ @publication = ] N'publication'
[ , [ @subscriber = ] N'subscriber' ]
[ , [ @subscriber_db = ] N'subscriber_db' ]
[ , [ @subscriber_security_mode = ] subscriber_security_mode ]
[ , [ @subscriber_login = ] N'subscriber_login' ]
[ , [ @subscriber_password = ] N'subscriber_password' ]
[ , [ @publisher_security_mode = ] publisher_security_mode ]
[ , [ @publisher_login = ] N'publisher_login' ]
[ , [ @publisher_password = ] N'publisher_password' ]
[ , [ @job_login = ] N'job_login' ]
[ , [ @job_password = ] N'job_password' ]
[ , [ @job_name = ] N'job_name' ]
[ , [ @frequency_type = ] frequency_type ]
[ , [ @frequency_interval = ] frequency_interval ]
[ , [ @frequency_relative_interval = ] frequency_relative_interval ]
[ , [ @frequency_recurrence_factor = ] frequency_recurrence_factor ]
[ , [ @frequency_subday = ] frequency_subday ]
[ , [ @frequency_subday_interval = ] frequency_subday_interval ]
[ , [ @active_start_time_of_day = ] active_start_time_of_day ]
[ , [ @active_end_time_of_day = ] active_end_time_of_day ]
[ , [ @active_start_date = ] active_start_date ]
[ , [ @active_end_date = ] active_end_date ]
[ , [ @enabled_for_syncmgr = ] N'enabled_for_syncmgr' ]
[ ; ]
The name of the publication. @publication is sysname, with no default.
The name of the Subscriber. @subscriber is sysname, with a default of NULL
.
The name of the subscription database. @subscriber_db is sysname, with a default of NULL
.
The security mode to use when connecting to a Subscriber when synchronizing. @subscriber_security_mode is smallint, with a default of 1
. The following values define the security mode:
0
specifies SQL Server authentication.1
specifies Windows authentication.2
specifies Microsoft Entra password authentication, starting with SQL Server 2022 (16.x) CU 6.3
specifies Microsoft Entra integrated authentication, starting with SQL Server 2022 (16.x) CU 6.4
specifies Microsoft Entra token authentication, starting with SQL Server 2022 (16.x) CU 6.Belangrijk
When possible, use Windows authentication.
The Subscriber login to use when connecting to a Subscriber when synchronizing. @subscriber_login is sysname, with a default of NULL
. @subscriber_login is required if @subscriber_security_mode is set to 0
.
The Subscriber password for SQL Server Authentication. @subscriber_password is sysname, with a default of NULL
. @subscriber_password is required if @subscriber_security_mode is set to 0
. If a subscriber password is used, it's automatically encrypted.
Belangrijk
When possible, prompt users to enter security credentials at runtime. If you must store credentials in a script file, you must secure the file to prevent unauthorized access.
The security mode to use when connecting to a Publisher when synchronizing. @publisher_security_mode is smallint, with a default of 1
. The following values define the security mode:
0
specifies SQL Server authentication.1
specifies Windows authentication.2
specifies Microsoft Entra password authentication, starting with SQL Server 2022 (16.x) CU 6.3
specifies Microsoft Entra integrated authentication, starting with SQL Server 2022 (16.x) CU 6.4
specifies Microsoft Entra token authentication, starting with SQL Server 2022 (16.x) CU 6.Belangrijk
When possible, use Windows authentication.
The login to use when connecting to a Publisher when synchronizing. @publisher_login is sysname, with a default of NULL
.
The password used when connecting to the Publisher. @publisher_password is sysname, with a default of NULL
.
Belangrijk
Do not use a blank password. Use a strong password. When possible, prompt users to enter security credentials at runtime. If you must store credentials in a script file, you must secure the file to prevent unauthorized access.
The login for the Windows account under which the agent runs. @job_login is nvarchar(257), with a default of NULL
. This Windows account is always used for agent connections to the Distributor and for connections to the Subscriber and Publisher when using Windows Integrated authentication.
The password for the Windows account under which the agent runs. @job_password is sysname, with no default.
Belangrijk
When possible, prompt users to enter security credentials at runtime. If you must store credentials in a script file, you must secure the file to prevent unauthorized access.
The name of an existing agent job. @job_name is sysname, with a default of NULL
. This parameter is only specified when the subscription is synchronized using an existing job instead of a newly created job (the default). If you aren't a member of the sysadmin fixed server role, you must specify job_login and job_password when you specify @job_name.
A value indicating when the Merge Agent runs. @frequency_type is int, and can be one of the following values.
Value | Description |
---|---|
1 |
One time |
2 |
On demand |
4 |
Daily |
8 |
Weekly |
16 |
Monthly |
32 |
Monthly relative |
64 |
Autostart |
128 |
Recurring |
NULL (default) |
Notitie
Specifying a value of 64
causes the Merge Agent to run in continuous mode. This corresponds to setting the -Continuous
parameter for the agent. For more information, see Replication Merge Agent.
The days that the Merge Agent runs. @frequency_interval is int, and can be one of the following values.
Value | Description |
---|---|
1 |
Sunday |
2 |
Monday |
3 |
Tuesday |
4 |
Wednesday |
5 |
Thursday |
6 |
Friday |
7 |
Saturday |
8 |
Day |
9 |
Weekdays |
10 |
Weekend days |
NULL (default) |
The date of the Merge Agent. This parameter is used when @frequency_type is set to 32
(monthly relative). @frequency_relative_interval is int, and can be one of the following values.
Value | Description |
---|---|
1 |
First |
2 |
Second |
4 |
Third |
8 |
Fourth |
16 |
Last |
NULL (default) |
The recurrence factor used by @frequency_type. @frequency_recurrence_factor is int, with a default of 0
.
How often to reschedule during the defined period. @frequency_subday is int, and can be one of the following values.
Value | Description |
---|---|
1 |
Once |
2 |
Second |
4 |
Minute |
8 |
Hour |
NULL (default) |
The interval for @frequency_subday. @frequency_subday_interval is int, with a default of NULL
.
The time of day when the Merge Agent is first scheduled, formatted as HHmmss
. @active_start_time_of_day is int, with a default of 0
.
The time of day when the Merge Agent stops being scheduled, formatted as HHmmss
. @active_end_time_of_day is int, with a default of 235959
.
The date when the Merge Agent is first scheduled, formatted as yyyyMMdd
. @active_start_date is int, with a default of 0
.
The date when the Merge Agent stops being scheduled, formatted as yyyyMMdd
. @active_end_date is int, with a default of 99991231
.
Specifies if the subscription can be synchronized through Windows Synchronization Manager. @enabled_for_syncmgr is nvarchar(5), with a default of false
.
false
, the subscription isn't registered with Synchronization Manager.true
, the subscription is registered with Synchronization Manager and can be synchronized without starting SQL Server Management Studio.0
(success) or 1
(failure).
sp_addmergepushsubscription_agent
is used in merge replication and uses functionality similar to sp_addpushsubscription_agent.
-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables
-- on the command line and in SQL Server Management Studio, see the
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".
DECLARE @publication AS sysname;
DECLARE @subscriber AS sysname;
DECLARE @subscriptionDB AS sysname;
DECLARE @hostname AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @subscriber = $(SubServer);
SET @subscriptionDB = N'AdventureWorksReplica';
SET @hostname = N'adventure-works\david8'
-- Add a push subscription to a merge publication.
USE [AdventureWorks2022];
EXEC sp_addmergesubscription
@publication = @publication,
@subscriber = @subscriber,
@subscriber_db = @subscriptionDB,
@subscription_type = N'push',
@hostname = @hostname;
--Add an agent job to synchronize the push subscription.
EXEC sp_addmergepushsubscription_agent
@publication = @publication,
@subscriber = @subscriber,
@subscriber_db = @subscriptionDB,
@job_login = $(Login),
@job_password = $(Password);
GO
Only members of the sysadmin fixed server role or db_owner fixed database role can execute sp_addmergepushsubscription_agent
.
gebeurtenis
31 mrt, 23 - 2 apr, 23
De grootste SQL-, Fabric- en Power BI-leerevenement. 31 maart – 2 april. Gebruik code FABINSIDER om $ 400 te besparen.
Zorg dat u zich vandaag nog registreert