Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Managed Instance
Changes properties of the Snapshot Agent for the specified publication. This stored procedure is executed at the Publisher on the publication database.
Important
When you configure 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
sp_changepublication_snapshot
[ @publication = ] N'publication'
[ , [ @frequency_type = ] frequency_type ]
[ , [ @frequency_interval = ] frequency_interval ]
[ , [ @frequency_subday = ] frequency_subday ]
[ , [ @frequency_subday_interval = ] frequency_subday_interval ]
[ , [ @frequency_relative_interval = ] frequency_relative_interval ]
[ , [ @frequency_recurrence_factor = ] frequency_recurrence_factor ]
[ , [ @active_start_date = ] active_start_date ]
[ , [ @active_end_date = ] active_end_date ]
[ , [ @active_start_time_of_day = ] active_start_time_of_day ]
[ , [ @active_end_time_of_day = ] active_end_time_of_day ]
[ , [ @snapshot_job_name = ] N'snapshot_job_name' ]
[ , [ @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' ]
[ , [ @publisher = ] N'publisher' ]
[ ; ]
The name of the publication. @publication is sysname, with no default.
Specifies the frequency with which to schedule the agent. @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) |
Specifies the days that the 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 units for @freq_subday_interval. @frequency_subday is int, and can be one of these 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 date the Snapshot Agent runs. @frequency_relative_interval is int, with a default of NULL
.
The recurrence factor used by @frequency_type. @frequency_recurrence_factor is int, with a default of NULL
.
The date when the Snapshot Agent is first scheduled, formatted as yyyyMMdd
. @active_start_date is int, with a default of NULL
.
The date when the Snapshot Agent stops being scheduled, formatted as yyyyMMdd
. @active_end_date is int, with a default of NULL
.
The time of day when the Snapshot Agent is first scheduled, formatted as HHmmss
. @active_start_time_of_day is int, with a default of NULL
.
The time of day when the Snapshot Agent stops being scheduled, formatted as HHmmss
. @active_end_time_of_day is int, with a default of NULL
.
The name of an existing Snapshot Agent job name if an existing job is being used. @snapshot_job_name is nvarchar(100), with a default of NULL
.
The security mode used by the agent when connecting to the Publisher. @publisher_security_mode is int, with a default of NULL
. A value of 0
must be specified for non-SQL Server Publishers.
0
specifies SQL Server authentication1
specifies Windows authenticationImportant
When possible, use Windows authentication.
The login used when connecting to the Publisher. @publisher_login is sysname, with a default of NULL
.
@publisher_login must be specified when @publisher_security_mode is 0
. If @publisher_login is NULL
and @publisher_security_mode is 1
, then the Windows account specified in @job_login is used when connecting to the Publisher.
The password used when connecting to the Publisher. @publisher_password is sysname, with a default of NULL
.
Important
Don't 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. You must supply this parameter when creating a new Snapshot Agent job. This can't be changed for a non-SQL Server publisher.
The password for the Windows account under which the agent runs. @job_password is sysname, with a default of NULL
. You must supply this parameter when creating a new Snapshot Agent job.
Important
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.
Specifies a non-SQL Server publisher. @publisher is sysname, with a default of NULL
.
Note
@publisher shouldn't be used when creating a Snapshot Agent at a SQL Server Publisher.
0
(success) or 1
(failure).
sp_changepublication_snapshot
is used in snapshot replication, transactional replication, and merge replication.
Only members of the sysadmin fixed server role or db_owner fixed database role can execute sp_changepublication_snapshot
.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today