Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

sp_repladdcolumn

SQL Server 2000

  New Information - SQL Server 2000 SP3.

Adds a column to an existing table article that has been published. Allows the new column to be added to all publishers that publish this table, or just add the column to a specific publication that publishes the table. This stored procedure is executed at the Publisher on the publication database.

Syntax

sp_repladdcolumn [ @source_object = ] 'source_object'
    , [ @column = ] 'column' ]
    [ , [ @typetext = ] 'typetext' ]
    [ , [ @publication_to_add = ] 'publication_to_add' ]
    [ , [ @schema_change_script = ] 'schema_change_script' ]
    [ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]

Arguments

[@source_object =] 'source_object'

Is the name of the table article that contains the new column to add. source_object is nvarchar(358), with no default.

[@column =] 'column'

Is the name of the column in the table to be added for replication. column is sysname, with no default.

[@typetext =] 'typetext'

Is the definition of the column being added. typetext is nvarchar(3000), with no default. For example, if the column order_filled is being added, and it is a single character field, not NULL, and has a default value of N, order_filled would be the column parameter, while the definition of the column, "char(1) NOT NULL DEFAULT 'N'" would be the typetext parameter value.

[@publication_to_add =] 'publication_to_add'

Is the name of the publication to which the new column is added. publication_to_add is nvarchar(4000), with a default of ALL. If all, then all publications containing this table will be affected. If publication_to_add is specified, then only this publication will have the new column added.

[@schema_change_script =] 'schema_change_script'

Is the path to the SQL script. schema_change_script is nvarchar(4000), with a default of NULL.

[@force_invalidate_snapshot = ] force_invalidate_snapshot

Enables or disables the ability to have a snapshot invalidated. force_invalidate_snapshot is a bit, with a default of 1. 1 specifies that changes to the article may cause the snapshot to be invalid, and if that is the case, a value of 1 gives permission for the new snapshot to occur. 0 specifies that changes to the article will not cause the snapshot to be invalid.

[@force_reinit_subscription = ] force_reinit_subscription

Enables or disables the ability to have the subscription reinitializated. force_reinit_subscription is a bit with a default of 0. 0 specifies that changes to the article will not cause the subscription to be reinitialized. 1 specifies that changes to the article may cause the subscription to be reinitialized, and if that is the case, a value of 1 gives permission for the subscription reinitialization to occur.

Return Code Values

0 (success) or 1 (failure)

Remarks

sp_repladdcolumn is used for all types of replication.

When using sp_repladdcolumn, if a schema change is made to an article that belongs to a publication that uses a DTS package, the schema change is not propagated to the Subscriber, and the custom procedures for INSERT/UPDATE/DELETE are not regenerated on the Subscribers. The user will need to regenerate the DTS package manually, and make the corresponding schema change at the Subscribers. If the schema update is not applied, the Distribution Agent may fail to apply subsequent modifications. Before making a schema change, make sure there are no pending transactions to be delivered. For more information, see How Transforming Published Data Works.

When typetext is assigned a default value that is a nondeterministic function (for example, 'datetime not null default getdate()'), non-convergence can occur after adding the new column because the function will be executed at the subscriber in order to load a default value into the column. 

Timestamp and computed columns will be filtered out for character mode publications. If adding a timestamp or computed column using sp_repladdcolumn, subscriptions of such publications will not receive this new column.

Important  A backup of the publication database should be performed after sp_repladdcolumn has been executed. Failure to do so can cause a merge failure after a restore of the publication database.

Permissions

Only members of the sysadmin fixed server role or db_owner fixed database role can execute sp_repladdcolumn.

See Also

System Stored Procedures

Show:
© 2014 Microsoft. All rights reserved.