Creates an article and adds it to a publication.
sp_addarticle [@publication =] 'publication', [@article =] 'article', [@source_table =] 'source_table'
[,[@destination_table =] 'destination_table']
[,[@vertical_partition =] 'vertical_partition']
[,[@type =] 'type'] [,[@filter =] 'filter'] [,[@sync_object =] 'sync_object']
[,[@ins_cmd =] 'ins_cmd'] [,[@del_cmd =] 'del_cmd']
[,[@upd_cmd =] 'upd_cmd'] [,[@creation_script =] 'creation_script']
[,[@description =] 'description']
[,[@pre_creation_cmd =] 'pre_creation_cmd']
[,[@filter_clause =] 'filter_clause'] [,[@schema_option =] schema_option]
[,[@destination_owner =] 'destination_owner'] [,[@status =] status]
[,[@source_owner =] 'source_owner']
[,[@sync_object_owner =] 'sync_object_owner']
[,[@filter_owner =] 'filter_owner'] [,[@source_object =] 'source_object']
| Value | Description |
|---|---|
| logbased | Log-based article. |
| logbased manualfilter | Log-based article with manual filter. |
| logbased manualview | Log-based article with manual view. |
| logbased manualboth | Log-based article with manual filter and manual view. |
| proc exec | Replicates the execution of the stored procedure to all Subscribers of the article. |
| serializable proc exec | Replicates the execution of the stored procedure only if it is executed within the context of a serializable transaction. |
| NULL (default) |
| Value | Description |
|---|---|
| NONE | No action is taken. |
| CALL sp_MSins_article (default) | Calls a stored procedure to be executed at the Subscriber. To use this method of replication, use @schema_option to specify automatic creation of the stored procedure, or create the specified stored procedure in the destination database of each Subscriber of the article. |
| SQL or NULL | Replicates an INSERT statement. The INSERT statement is provided values for all columns published in the article. This command is replicated on inserts:
|
| Value | Description |
|---|---|
| NONE | No action is taken. |
| CALL sp_MSdel_article (default) | Calls a stored procedure to be executed at the Subscriber. To use this method of replication, use @schema_option to specify automatic creation of the stored procedure, or create the specified stored procedure in the destination database of each Subscriber of the article. |
| XCALL sp_MSdel_article | Calls a stored procedure taking XCALL style parameters. For more information, see Using Custom Stored Procedures in Articles. |
| SQL or NULL | Replicates a DELETE statement. The DELETE statement is provided all primary key column values. This command is replicated on deletes:
|
| Value | Description |
|---|---|
| NONE | No action is taken. |
| CALL sp_MSupd_article | Calls a stored procedure to be executed at the Subscriber. To use this method of replication, use @schema_option to specify automatic creation of the stored procedure, or create the specified stored procedure in the destination database of each Subscriber of the article. |
| MCALL sp_MSupd_article (default) | Calls a stored procedure taking MCALL style parameters. For an example, see sp_scriptmappedupdproc. |
| XCALL sp_MSupd_article | Calls a stored procedure taking XCALL style parameters. For more information, see Using Custom Stored Procedures in Articles. |
| SQL or NULL | Replicates an UPDATE statement. The UPDATE statement is provided all column values and the primary key column values. This command is replicated on updates:
|
| Value | Description |
|---|---|
| none | Does not use a command. |
| delete | Deletes the destination table. |
| drop (default) | Drops the destination table. |
| truncate | Truncates the destination table. Is not valid for ODBC or OLE BD subscribers. |
| Value | Description |
|---|---|
| 0x0000000000000000 | Disables scripting by the Snapshot Agent and uses the provided CreationScript. |
| 0x0000000000000001 | Generates the object creation (CREATE TABLE, CREATE PROCEDURE, and so on). |
| 0x0000000000000002 | Generates custom stored procedures for the article if defined. |
| 0x0000000000000010 | Generates a corresponding clustered index. |
| 0x0000000000000020 | Converts user-defined data types to base data types. |
| 0x0000000000000040 | Generates corresponding nonclustered index(es). |
| 0x0000000000000080 | Includes declared referential integrity on the primary keys. |
| 0x0000000000000073 (default) | Generates the CREATE TABLE statement, creates clustered index, creates nonclustered index(es), converts user-defined data types to base data types, and generates custom stored procedure scripts to be applied at the Subscriber. |
| 0x0000000000000001 | Default for stored procedure articles. |
| Value | Description |
|---|---|
| 0 | No additional properties. |
| 8 | Include the column name in INSERT statements. |
| 16 (default) | Use parameterized statements. |
| 24 | Both include the column name in INSERT statements and use parameterized statements. |
0 (success) or 1 (failure)
sp_addarticle is used in snapshot, transactional, and merge replication.
If vertical_partition is true, sp_addarticle defers the creation of the view until sp_articleview is called (after the last sp_articlecolumn is added).
If the publication allows immediate-updating subscriptions and the published table does not have a timestamp column, sp_addarticle automatically adds a timestamp column to the table.
Only members of the sysadmin fixed server role or db_owner fixed database role can execute sp_addarticle.