Creating the Publication

You create publications for SQL Server Compact 3.5 by using standard SQL Server replication tools and techniques. The easiest way to create a publication is by using the Publication Wizard. You can also create the publication by using the sp_addmergepublication stored procedure.

Using the Publication Wizard to Create a Publication

The easiest way to create a publication is to use the Publication Wizard in SQL Server. The wizard provides a graphical user interface that lets you select the Publisher, the publication type, and the articles to publish. It also lets you configure filtering for the publication.

When you create a publication for SQL Server Compact 3.5 Subscribers by using the Publication Wizard, you must select the following options:

  • On the Publication Type page, select Merge publication.
  • Enable Windows CE Subscribers:
    • In SQL Server 2005 and later versions, on the Subscriber Type page, select SQL Server 2005 Mobile, SQL Server Compact 3.1 and higher.
      By enabling Subscribers, character mode snapshots are automatically configured for the publication. In SQL Server 2005 and later versions, Web synchronization is also enabled.

If this is the first publication created for this server, the Publication Wizard prompts you to configure the default snapshot folder location. The snapshot folder holds the snapshot files that contain the schema and data for published tables. The IIS user must be able to read these snapshot files so that it can download the files to the smart device.

Note

The snapshot folder default location is a local path in the installation folder for SQL Server. You must change this path to a shared folder so that the IIS user can access the snapshot from over the network. For more information about creating and configuring the snapshot folder, see Configuring the Snapshot Folder.

For more information about using the Publication Wizard, see "Replication Wizards" in SQL Server Books Online.

Using sp_addmergepublication to Create a Publication

You can also create a new publication by using the sp_addmergepublication stored procedure. If you use the stored procedure, certain arguments must have specific values to permit compact database Subscribers. The following table lists the arguments and their required values.

Argument Required Value SQL Server versions

@sync_mode

'character'

SQL Server 2005 or later versions

@allow_pull

true

SQL Server 2005 or later versions

@allow_anonymous

true

SQL Server 2005 or later versions

@centralized_conflicts

true

SQL Server 2005 or later versions

@compress_snapshot

false

SQL Server 2005 or later versions

@allow_web_synchronization

true

SQL Server 2005 or later versions

@conflict_logging

both or Publisher

SQL Server 2005 or later versions

@keep_partition_changes

true

SQL Server 2005 or later versions

Besides the required arguments in the previous table, the following rules apply to additional arguments you can use with the sp_addmergepublication stored procedure:

  • @alt_snapshot_folder is only supported if @snapshot_in_defaultfolder is set to 'false'.
  • @pre-snapshot_script is ignored by Subscribers.
  • @post_snapshot_script is ignored by Subscribers.
  • @keep_partition_changes is a deprecated parameter in SQL Server and should not be used. Instead, set @use_partition_groups to 'true' to improve synchronization performance with filtered articles.
  • @allow_synctoalternate is ignored by Subscribers.

Note

When @partition_options is set to 1, 2 or 3, SQL Server Compact 3.5 cannot help protect against out-of-partition inserts. Therefore, during synchronization, they are ignored by the Publisher but are not logged as a conflict or deleted at the Subscriber, thereby causing divergence. The developer must protect out-of-partition inserts from occurring at the application layer.

See Also

Concepts

Adding an Article to a Publication
Securing the Publication

Help and Information

Getting Assistance (SQL Server Compact 3.5 Service Pack 1)