title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | helpviewer_keywords | monikerRange | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
View and Modify Publication Properties |
Learn how to view and modify publication properties in SQL Server by using SQL Server Management Studio, Transact-SQL, or Replication Management Objects. |
MashaMSFT |
mathoma |
03/17/2017 |
sql |
replication |
how-to |
updatefrequency5 |
|
=azuresqldb-mi-current||>=sql-server-2016 |
[!INCLUDEsql-asdbmi] This topic describes how to view and modify publication properties in [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull], [!INCLUDEtsql], or Replication Management Objects (RMO).
In This Topic
-
Before you begin:
-
To view and modify publication properties, using:
- Some properties cannot be modified after a publication has been created, and others cannot be modified if there are subscriptions to the publication. Properties that cannot be modified are displayed as read-only.
- After a publication is created, some property changes require a new snapshot. If a publication has subscriptions, some changes also require all subscriptions to be reinitialized. For more information, see Change Publication and Article Properties and Add Articles to and Drop Articles from Existing Publications.
View and modify publication properties in the Publication Properties - <Publication> dialog box, which is available in [!INCLUDEssManStudioFull] and Replication Monitor. For information about starting Replication Monitor, see Start the Replication Monitor.
The Publication Properties - <Publication> dialog box includes the following pages:
-
The General page includes the publication name and description, the database name, the type of publication, and the subscription expiration settings.
-
The Articles page corresponds to the Articles page in the New Publication Wizard. Use this page to add and delete articles, and to change properties and column filtering for articles.
-
The Filter Rows page corresponds to the Filter Table Rows page in the New Publication Wizard. Use this page to add, edit, and delete static row filters for all types of publications, and to add, edit, and delete parameterized row filters and join filters for merge publications.
-
The Snapshot page allows you to specify the format and location of the snapshot, whether the snapshot should be compressed, and scripts to run before and after the snapshot is applied.
-
The FTP Snapshot page (for snapshot and transactional publications, and merge publications for Publishers running versions prior to SQL Server 2005) allows you to specify whether Subscribers can download snapshot files through File Transfer Protocol (FTP).
-
The FTP Snapshot and Internet page (for merge publications from Publishers running SQL Server 2005 or later) allows you to specify whether Subscribers can download snapshot files through FTP, and whether Subscribers can synchronize subscriptions through HTTPS.
-
The Subscription Options page allows you to set a number of options that apply to all subscriptions. The options differ depending on the type of publication.
-
The Publication Access List page allows you to specify which logins and groups can access a publication.
-
The Agent Security page allows you to access settings for the accounts under which the following agents run and make connections to the computers in a replication topology: the Snapshot Agent for all publications; the Log Reader Agent for all transactional publications; and the Queue Reader Agent for transactional publications that allow queued updating subscriptions.
-
The Data Partitions page (for merge publications from Publishers running SQL Server 2005 or later) allows you to specify whether Subscribers to publications with parameterized filters can request a snapshot if one is not available. It also allows you to generate snapshots for one or more partitions, either once or on a recurring schedule.
-
Connect to the Publisher in [!INCLUDEssManStudio], and then expand the server node.
-
Expand the Replication folder, and then expand the Local Publications folder.
-
Right-click a publication, and then click Properties.
-
Modify any properties if necessary, and then click OK.
-
Expand a Publisher group in the left pane of Replication Monitor, and then expand a Publisher.
-
Right-click a publication, and then click Properties.
-
Modify any properties if necessary, and then click OK.
Publications can be modified and their properties returned programmatically using replication stored procedures. The stored procedures that you use will depend on the type of publication.
- Execute sp_helppublication, specifying the name of the publication for the @publication parameter. If you do not specify this parameter, information on all publications at the Publisher is returned.
-
Execute sp_changepublication, specifying the publication property to change in the @property parameter and the new value of this property in the @value parameter.
[!NOTE]
If the change will require the generation of a new snapshot, you must also specify a value of 1 for @force_invalidate_snapshot, and if the change will require that Subscribers be reinitialized, you must specify a value of 1 for @force_reinit_subscription. For more information on the properties that, when changed, require a new snapshot or reinitialization, see Change Publication and Article Properties.
- Execute sp_helpmergepublication, specifying the name of the publication for the @publication parameter. If you do not specify this parameter, information on all publications at the Publisher is returned.
-
Execute sp_changemergepublication, specifying the publication property being changed in the @property parameter and the new value of this property in the @value parameter.
[!NOTE]
If the change will require the generation of a new snapshot, you must also specify a value of 1 for @force_invalidate_snapshot, and if the change will require that Subscribers be reinitialized, you must specify a value of 1 for @force_reinit_subscription For more information on the properties that, when changed, require a new snapshot or reinitialization, see Change Publication and Article Properties.
- Execute sp_helppublication_snapshot, specifying the name of the publication for the @publication parameter.
- Execute sp_changepublication_snapshot, specifying one or more of the new snapshot properties for the appropriate snapshot parameters.
This transactional replication example returns the properties of the publication.
:::code language="sql" source="../codesnippet/tsql/view-and-modify-publicat_1.sql":::
This transactional replication example disables schema replication for the publication.
:::code language="sql" source="../codesnippet/tsql/view-and-modify-publicat_2.sql":::
This merge replication example returns the properties of the publication.
:::code language="sql" source="../codesnippet/tsql/view-and-modify-publicat_3.sql":::
This merge replication example disables schema replication for the publication.
:::code language="sql" source="../codesnippet/tsql/view-and-modify-publicat_4.sql":::
You can modify publications and access their properties programmatically by using Replication Management Objects (RMO). The RMO classes that you use to view or modify publication properties depend on the type of publication.
-
Create a connection to the Publisher by using the xref:Microsoft.SqlServer.Management.Common.ServerConnection class.
-
Create an instance of the xref:Microsoft.SqlServer.Replication.TransPublication class, set the xref:Microsoft.SqlServer.Replication.Publication.Name%2A and xref:Microsoft.SqlServer.Replication.Publication.DatabaseName%2A properties for the publication, and set the xref:Microsoft.SqlServer.Replication.ReplicationObject.ConnectionContext%2A property to the connection created in step 1.
-
Call the xref:Microsoft.SqlServer.Replication.ReplicationObject.LoadProperties%2A method to get the properties of the object. If this method returns false, either the publication properties in step 2 were defined incorrectly or the publication does not exist.
-
(Optional) To change properties, set a new value for one or more of the settable properties. Use the logical AND operator (& in Microsoft Visual C# and And in Microsoft Visual Basic) to determine if a given xref:Microsoft.SqlServer.Replication.PublicationAttributes value is set for the xref:Microsoft.SqlServer.Replication.Publication.Attributes%2A property. Use the inclusive logical OR operator (| in Visual C# and Or in Visual Basic) and the exclusive logical OR operator (^ in Visual C# and Xor in Visual Basic) to change the xref:Microsoft.SqlServer.Replication.PublicationAttributes values for the xref:Microsoft.SqlServer.Replication.Publication.Attributes%2A property.
-
(Optional) If you specified a value of true for xref:Microsoft.SqlServer.Replication.ReplicationObject.CachePropertyChanges%2A, call the xref:Microsoft.SqlServer.Replication.ReplicationObject.CommitPropertyChanges%2A method to commit changes on the server. If you specified a value of false for xref:Microsoft.SqlServer.Replication.ReplicationObject.CachePropertyChanges%2A (the default), changes are sent to the server immediately.
-
Create a connection to the Publisher by using the xref:Microsoft.SqlServer.Management.Common.ServerConnection class.
-
Create an instance of the xref:Microsoft.SqlServer.Replication.MergePublication class, set the xref:Microsoft.SqlServer.Replication.Publication.Name%2A and xref:Microsoft.SqlServer.Replication.Publication.DatabaseName%2A properties for the publication, and set the xref:Microsoft.SqlServer.Replication.ReplicationObject.ConnectionContext%2A property to the connection created in step 1.
-
Call the xref:Microsoft.SqlServer.Replication.ReplicationObject.LoadProperties%2A method to get the properties of the object. If this method returns false, either the publication properties in step 2 were defined incorrectly or the publication does not exist.
-
(Optional) To change properties, set a new value for one or more of the settable properties. Use the logical AND operator (& in Visual C# and And in Visual Basic) to determine if a given xref:Microsoft.SqlServer.Replication.PublicationAttributes value is set for the xref:Microsoft.SqlServer.Replication.Publication.Attributes%2A property. Use the inclusive logical OR operator (| in Visual C# and Or in Visual Basic) and the exclusive logical OR operator (^ in Visual C# and Xor in Visual Basic) to change the xref:Microsoft.SqlServer.Replication.PublicationAttributes values for the xref:Microsoft.SqlServer.Replication.Publication.Attributes%2A property.
-
(Optional) If you specified a value of true for xref:Microsoft.SqlServer.Replication.ReplicationObject.CachePropertyChanges%2A, call the xref:Microsoft.SqlServer.Replication.ReplicationObject.CommitPropertyChanges%2A method to commit changes on the server. If you specified a value of false for xref:Microsoft.SqlServer.Replication.ReplicationObject.CachePropertyChanges%2A (the default), changes are sent to the server immediately.
This example sets publication attributes for a transactional publication. The changes are cached until explicitly sent to the server.
[!code-csHowTo#rmo_ChangeTranPub_cached]
[!code-vbHowTo#rmo_vb_ChangeTranPub_cached]
This example disables DDL replication for a merge publication.
[!code-csHowTo#rmo_ChangeMergePub_ddl]
[!code-vbHowTo#rmo_vb_ChangeMergePub_ddl]
Publish Data and Database Objects
Change Publication and Article Properties
Make Schema Changes on Publication Databases
Replication System Stored Procedures Concepts
Add Articles to and Drop Articles from a Publication (SQL Server Management Studio)
View Information and Perform Tasks using Replication Monitor
View and Modify Article Properties