Creating the Publication

You create publications for Microsoft SQL Server 2005 Compact Edition (SQL Server Compact Edition) 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.

Note

In SQL Server 2000, the Publication Wizard is named the Create Publication Wizard. In SQL Server 2005, it is named the New Publication Wizard. For simplicity, it is referred to here as the Publication Wizard.

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 Edition 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, on the Subscriber Type page, select SQL Server Compact Edition.
    • In SQL Server 2000, on the Specify SubscriberTypes page, select Devices running SQL Server Compact Edition.
      By enabling Windows CE subscribers, character mode snapshots are automatically configured for the publication. In SQL Server 2005, 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 SQL Server Compact Edition subscribers. The following table lists the arguments and their required values.

Argument Required Value SQL Server 2000 or SQL Server 2005

@sync_mode

'character'

Both

@allow_pull

true

Both

@allow_anonymous

true

Both

@centralized_conflicts

true

SQL Server 2000

@compress_snapshot

false

Both

@allow_web_synchronization

true

SQL Server 2005 only

@conflict_logging

both or publisher

SQL Server 2005 only

@keep_partition_changes

true

SQL Server 2000 only

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 SQL Server Compact Edition Subscribers.
  • @post_snapshot_script is ignored by SQL Server Compact Edition Subscribers.
  • @keep_partition_changes is a deprecated parameter in SQL Server 2005 and should not be used. Instead, set @use_partition_groups to 'true' to improve synchronization performance with filtered articles.
  • @allow_synctoalternate is ignored by SQL Server Compact Edition subscribers.

Note

When @partition_options is set to 1, 2 or 3, then SQL Server Compact Edition 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 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 SQL Server Compact Edition Assistance