sp_changearticle (Transact-SQL)
Changes the properties of an article in a transactional or snapshot publication. This stored procedure is executed at the Publisher on the publication database.
sp_changearticle [ [@publication= ] 'publication' ]
[ , [ @article= ] 'article' ]
[ , [ @property= ] 'property' ]
[ , [ @value= ] 'value' ]
[ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
[ , [ @force_reinit_subscription = ] force_reinit_subscription ]
[ , [ @publisher = ] 'publisher' ]
sp_changearticle is used in snapshot replication and transactional replication.
When an article belongs to a publication that supports peer-to-peer transactional replication, you can only change the description, ins_cmd, upd_cmd, and del_cmd properties.
Changing any of the following properties requires that a new snapshot be generated, and you must specify a value of 1 for the force_invalidate_snapshot parameter:
-
del_cmd
-
dest_table
-
destination_owner
-
ins_cmd
-
pre_creation_cmd
-
schema_options
-
upd_cmd
Changing any of the following properties requires that existing subscriptions be reinitialized, and you must specify a value of 1 for the force_reinit_subscription parameter.
-
del_cmd
-
dest_table
-
destination_owner
-
filter
-
ins_cmd
-
status
-
upd_cmd
Within an existing publication, you can use sp_changearticle to change an article without having to drop and re-create the entire publication.
Note
|
|---|
|
When changing the value of schema_option, the system does not perform a bitwise update. This means that when you set schema_option using sp_changearticle, existing bit settings may be turned off. To retain the existing settings, you should perform & (Bitwise AND) between the value that you are setting and the current value of schema_option, which can be determined by executing sp_helparticle. |
Valid Schema Options
The following table describes the allowable values of schema_option based upon the replication type (shown across the top) and the article type (shown down the first column).
|
Article type |
Replication type |
|
|---|---|---|
|
|
Transactional |
Snapshot |
|
logbased |
All options |
All options but 0x02 |
|
logbased manualfilter |
All options |
All options but 0x02 |
|
logbased manualview |
All options |
All options but 0x02 |
|
indexed view logbased |
All options |
All options but 0x02 |
|
indexed view logbased manualfilter |
All options |
All options but 0x02 |
|
indexed view logbased manualview |
All options |
All options but 0x02 |
|
indexed view logbase manualboth |
All options |
All options but 0x02 |
|
proc exec |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
|
serializable proc exec |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
|
proc schema only |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
|
view schema only |
0x01, 0x010, 0x020, 0x040, 0x0100, 0x2000, 0x40000, 0x100000, 0x200000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x40000000, and 0x80000000 |
0x01, 0x010, 0x020, 0x040, 0x0100, 0x2000, 0x40000, 0x100000, 0x200000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x40000000, and 0x80000000 |
|
func schema only |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
0x01, 0x20, 0x2000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, and 0x80000000 |
|
indexed view schema only |
0x01, 0x010, 0x020, 0x040, 0x0100, 0x2000, 0x40000, 0x100000, 0x200000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x40000000, and 0x80000000 |
0x01, 0x010, 0x020, 0x040, 0x0100, 0x2000, 0x40000, 0x100000, 0x200000, 0x400000, 0x800000, 0x2000000, 0x8000000, 0x40000000, and 0x80000000 |
Note
|
|---|
|
For queued updating publications, the schema_option value of 0x80 must be enabled. The supported schema_option values for non-SQL Server publications are: 0x01, 0x02, 0x10, 0x40, 0x80, 0x1000 and 0x4000. |
DECLARE @publication AS sysname; DECLARE @article AS sysname; DECLARE @option AS int; SET @publication = N'AdvWorksProductTran'; SET @article = N'Product'; SET @option = (SELECT CAST(0x0000000002030073 AS int)); -- Change the schema options to replicate schema with XML. USE [AdventureWorks2012] EXEC sp_changearticle @publication = @publication, @article = @article, @property = N'schema_option', @value = @option, @force_invalidate_snapshot = 1; GO