Specify Schema Options
This topic describes how to specify schema options in SQL Server 2014 by using SQL Server Management Studio or Transact-SQL. When you are publishing a table or view, you can control the object creation options that are replicated for the published object. You can set these option when the article is created, and you can also change them at a later time. If you do not explicitly specify these options for an article, a default set of options will be defined.
Note
The default schema options when using replication stored procedures may differ from the default options when articles are added using SQL Server Management Studio.
In This Topic
Before you begin:
To specify schema options, using:
Before You Begin
Limitations and Restrictions
- If you change schema options after a publication is created, you must generate a new snapshot.
Recommendations
- For the complete list of schema options, see the @schema_option parameter of sp_addarticle (Transact-SQL) and sp_addmergearticle (Transact-SQL).
Using SQL Server Management Studio
Specify schema options, such as whether to copy constraints and triggers to Subscribers, on the Properties tab of the Article Properties - <Article> dialog box. This tab is available in the New Publication Wizard and the Publication Properties - <Publication> dialog box. For more information about using the wizard and accessing the dialog box, see Create a Publication and View and Modify Publication Properties.
To specify schema options
On the Articles Page of the New Publication Wizard or Publication Properties - <Publication> dialog box, select an article, and then click Article Properties.
Select which articles schema option changes should apply to:
Click Set Properties of Highlighted <ObjectType> Article to launch the Article Properties - <ObjectName> dialog box; property changes made in this dialog box are applied only to the object that is highlighted in the object pane on the Articles page.
Click Set Properties of All <ObjectType> Articles to launch the Properties for All <ObjectType> Articles dialog box; property changes made in this dialog box are applied to all objects of that type in the object pane on the Articles page, including ones not yet selected for publication.
Note
Property changes made in the Properties for All <ObjectType> Articles dialog box override any made previously in the Article Properties - <ObjectName> dialog box. If, for example, you want to set a number of defaults for all articles of an object type, but also want to set some properties for individual objects, set the defaults for all articles first. Then set the properties for the individual objects.
In the Copy Objects and Settings to Subscriber and Destination Object sections of the Properties tab of the Article Properties - <Article> dialog box, specify values for the options.
Modify any properties if necessary, and then click OK.
If you are in the Publication Properties - <Publication> dialog box, click OK to save and close the dialog box.
Using Transact-SQL
Schema options are specified as a hexadecimal value that is the | (Bitwise OR) result of one or more options. For more information, see sp_addarticle and sp_addmergearticle.
Note
You must convert schema option values from binary to int before performing a bitwise operation. For more information, see CAST and CONVERT (Transact-SQL).
To specify schema options when defining an article for a snapshot or transactional publication
- At the Publisher on the publication database, execute sp_addarticle. Specify the name of the publication to which the article belongs for @publication, a name for the article for @article, the database object being published for @source_object, the type of database object for @type, and the | (Bitwise OR) result of one or more schema options for @schema_option. For more information, see Define an Article.
To specify schema options when defining an article for a merge publication
- At the Publisher on the publication database, execute sp_addmergearticle. Specify the name of the publication to which the article belongs for @publication, a name for the article for @article, the database object being published for @source_object, and the | (Bitwise OR) result of one or more schema options for @schema_option. For more information, see Define an Article.
To change schema options for an existing article in a snapshot or transactional publication
At the Publisher on the publication database, execute sp_helparticle. Specify the name of the publication to which the article belongs for @publication and the name of the article for @article. Note the value of the schema_option column in the result set.
Execute a & (Bitwise AND) operation using the value from step 1 and the desired schema option value to determine if the option is set.
If the result is 0, the option is not set.
If the result is the option value, the option is already set.
If the option is not set, execute a | (Bitwise OR) operation using the value from step 1 and the desired schema option value.
At the Publisher on the publication database, execute sp_changearticle. Specify the name of the publication to which the article belongs for @publication, the name of the article for @article, a value of schema_option for @property, and the hexadecimal result from step 3 for @value.
Run the Snapshot Agent to generate a new snapshot. For more information, see Create and Apply the Initial Snapshot.
To change schema options for an existing article in a merge publication
At the Publisher on the publication database, execute sp_helpmergearticle. Specify the name of the publication to which the article belongs for @publication and the name of the article for @article. Note the value of the schema_option column in the result set.
Execute a & (Bitwise AND) operation using the value from step 1 and the desired schema option value to determine if the option is set.
If the result is 0, the option is not set.
If the result is the option value, the option is already set.
If the option is not set, execute a | (Bitwise OR) operation using the value from step 1 and the desired schema option value.
At the Publisher on the publication database, execute sp_changemergearticle. Specify the name of the publication to which the article belongs for @publication, the name of the article for @article, a value of schema_option for @property, and the hexadecimal result from step 3 for @value.
Run the Snapshot Agent to generate a new snapshot. For more information, see Create and Apply the Initial Snapshot.
See Also
Publish Data and Database Objects
Article Options for Transactional Replication