Home Microsoft SQL Server DigiMailing iRN Contact


  No additional text.


-- Name:
--		sp_addpublication

-- Description:
--		Creates a snapshot or transactional publication. This stored procedure is executed at
--		the Publisher on the publication database.

-- Returns:
--		Return code (0 for success, 1 for failure)

-- Security:
--		Public

-- Notes:
--		Re-directs to call sp_MSrepl_addpublication in the correct db context (distributor for HREPL)

create procedure sys.sp_addpublication
    @publication                sysname,
    @taskid                        int = 0,                        -- backward compatible
    @restricted                    nvarchar (10) = N'false',        -- publication security
    @sync_method                nvarchar(40) = NULL,            -- (bcp) native, (bcp) character
                                                                -- NULL defaults to appropriate sync method for pub type
    @repl_freq                    nvarchar(10) = N'continuous',    -- continuous, snapshot
    @description                nvarchar (255) = NULL,
    @status                        nvarchar(8) = N'inactive',        -- publication status; 0=inactive, 1=active
    @independent_agent            nvarchar(5) = N'false',
    @immediate_sync                nvarchar(5) = NULL,
    @enabled_for_internet        nvarchar(5) = N'false',
    @allow_push                    nvarchar(5) = N'true',
    @allow_pull                    nvarchar(5) = N'false',
    @allow_anonymous            nvarchar(5) = N'false',
    -- SyncTran
    @allow_sync_tran            nvarchar(5) = N'false',
    @autogen_sync_procs            nvarchar(5) = NULL,                -- auto gen sync tran procs per article
    @retention                    int = 336,                        -- 14  days
    @allow_queued_tran            nvarchar(5) = N'false',
    -- Portable Snapshot
    @snapshot_in_defaultfolder    nvarchar(5) = N'true',
    @alt_snapshot_folder        nvarchar(255) = NULL,
    -- Snapshot pre/post- commands
    @pre_snapshot_script        nvarchar(255) = NULL,
    @post_snapshot_script        nvarchar(255) = NULL,
    -- Snapshot compression
    @compress_snapshot            nvarchar(5) = N'false',
    -- Post 7.0 FTP
    @ftp_address                sysname = NULL,
    @ftp_port                    int = 21,
    @ftp_subdirectory            nvarchar(255) = NULL,
    @ftp_login                    sysname = N'anonymous',
    @ftp_password                sysname = NULL,
    @allow_dts                    nvarchar(5) = N'false',
    @allow_subscription_copy    nvarchar(5) = N'false',
    @conflict_policy            nvarchar(100) = NULL,            -- NULL, 'pub wins', 'sub reinit', 'sub wins'
    @centralized_conflicts        nvarchar(5) = NULL,                -- NULL, 'true', 'false'
    @conflict_retention            int = 14,
    @queue_type                    nvarchar(10) = NULL,            -- NULL, 'sql'
    @add_to_active_directory    nvarchar(10) = N'false',
    @logreader_job_name            sysname = NULL,
    @qreader_job_name            sysname = NULL,
    @publisher                    sysname = NULL,
    -- Backup subscription support
    @allow_initialize_from_backup        nvarchar(5) = NULL,        -- NULL, 'false', 'true'
    @replicate_ddl                int = NULL,
    -- PeerToPeer
    @enabled_for_p2p            nvarchar(5) = N'false',
    @publish_local_changes_only    nvarchar(5)    = N'false',
    -- Heterogeneous subscriptions
    @enabled_for_het_sub        nvarchar(5) = N'false',
    -- PeerToPeer conflict detection
    @p2p_conflictdetection    nvarchar(5) = N'false',
    @p2p_originator_id         int = NULL,
    @p2p_continue_onconflict    nvarchar(5) = N'false',
	@allow_partition_switch		nvarchar(5) = N'false',
	@replicate_partition_switch nvarchar(5) = NULL
    set nocount on
    DECLARE @cmd  nvarchar(4000)
                ,@retcode  int
                ,@publisher_type sysname

    EXEC @retcode = sys.sp_MSrepl_getpublisherinfo @publisher = @publisher,
                                                                        @publisher_type = @publisher_type OUTPUT,
                                                                        @rpcheader = @cmd OUTPUT
    IF @retcode != 0 or @@error !=0
        RETURN 1

    -- Add sp
    select @publisher = UPPER(@publisher)
            ,@cmd = @cmd + N'sys.sp_MSrepl_addpublication'

    EXEC @retcode = @cmd

    RETURN (@retcode)

Last revision 2008RTM
See also

  sp_addpublication_snapshot (Procedure)
sp_grant_publication_access (Procedure)
sp_link_publication (Procedure)
sp_MSadd_publication (Procedure)
sp_MSdrop_replcom (Procedure)
sp_MSdrop_repltran (Procedure)
sp_MSrepl_addpublication (Procedure)
sp_MSrepl_addpublication_snapshot (Procedure)
sp_MSrepl_droppublication (Procedure)


  Query a named instance
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
Zoekmachine optimalisatie
SQL Servers hidden objects
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
sIFR; de combinatie tussen HTML en Flash