sp_addpublication Replication Stored Procedure

Creates a publication.

Syntax

sp_addpublication publication, taskid,
    
[, @restricted = {'true' | 'false'}
    [, @sync_method = {'native' | 'character'}
    
[, @repl_freq = {'continuous' | 'snapshot'}
    [, @description = 'string description'
    [, @status= {'inactive' | 'active'}]]]]]

where

publication
Names the publication to create. The name must be unique within the database.
taskid
Is a unique scheduler task ID (must be created before the publication).
restricted
Specifies who can view the publication. If set to false (the default), the publication can be viewed by all (open enrollment). If set to true, the publication can be viewed only by authorized subscription servers.
sync_method
Specifies the synchronization mode. If set to native (the default), produces native-mode BCP output of all tables. If set to character, produces character-mode BCP output of all tables.
repl_freq
Specifies that if set to continuous (the default), the publisher provides output of all log-based transactions. If set to snapshot, the publisher produces only scheduled synchronization events.
description
Is an optional descriptive entry for the publication job.
status
Specifies when publication data will be available. If set to inactive (the default), publication data will not be available for subscribers when the publication is first created (they can subscribe, but the subscription will not be processed). If set to active, publication data will immediately be available for subscribers.

Remarks

Only the system administrator or the database owner can add a publication.

Example

This example creates the publication authors_publication, using a preexisting sync task with taskid equal to 1.

sp_addpublication authors_publication, 1, @status=active, 
@description='Full Authors Table'

Permission

Execute permission defaults to the database owner and the system administrator.

Tables Used

syspublications, sysdatabases

See Also

sp_addarticle sp_droppublication
sp_articlecolumn sp_enumfullsubscribers
sp_changearticle sp_helparticle
sp_changepublication sp_helparticlecolumns
sp_droparticle sp_helppublication