Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrepl_subscriptionagentjobcontrol

  No additional text.


Syntax
create procedure sys.sp_MSrepl_subscriptionagentjobcontrol
(
    @publication    sysname,
    @subscriber     sysname,
    @subscriber_db  sysname,
    @publisher      sysname,
    @publisher_type sysname,
    @action         tinyint
)
as
begin
    set nocount on

    declare @PUSH int
    set @PUSH = 0

    declare @retcode            int
    declare @independent_agent  int
    declare @pubid              int
    declare @distributor        sysname
    declare @distributor_rpc    sysname
    declare @distribution_db    sysname
    declare @publisher_db       sysname
    declare @subscriber_id      int
    declare @procedure          nvarchar(4000)
    declare @start              tinyint
    set @retcode = 0
    set @independent_agent = 0
    set @pubid = null
    set @publisher_db = db_name()
    set @start = 0

    -- Security check
    exec @retcode = sys.sp_MSreplcheck_publish
    if @@error <> 0 or @retcode <> 0
        return 1

    -- Check to see if database is activated for publication
    if sys.fn_MSrepl_istranpublished(db_name(),1) <> 1
    begin
        -- "This database is no enabled for publication."
        raiserror (14013, 16, -1)
    end

    -- Parameter check: @publication
    if @publication is null
    begin
        -- "The parameter @publication cannot be NULL."
        raiserror (14043, 16, -1, '@publication', 'sp_MSrepl_startsubscription_agent')
        return 1
    end

    exec @retcode = sys.sp_validname @publication
    if @@error <> 0 or @retcode <> 0
        return 1

    -- Parameter Check : @publisher
    if @publisher is null
    begin
        set @publisher = publishingservername()
    end

    -- Retrieve publication options
    select @pubid               = pubid,
           @independent_agent   = independent_agent
      from dbo.syspublications
     where name = @publication
       and pubid = sys.fn_MSrepl_getpubid(@publication, @publisher, @publisher_type)

    if @pubid is null
    begin
        -- "The publication '@publication' does not exist."
        raiserror (20026, 16, -1, @publication)
        return 1
    end

    -- Check to see if the subscription exists
    if not exists (select ss.*
                     from sysextendedarticlesview seav
                     join syssubscriptions ss
                       on ss.artid = seav.artid
                    where seav.pubid = @pubid
                      and ss.srvname = upper(@subscriber)
                      and ss.dest_db = @subscriber_db
                      and subscription_type = @PUSH)
    begin
        -- "The subscription could not be found."
        raiserror (20021, 16, -1)
        return 1
    end

    exec @retcode = sys.sp_helpdistributor
            @rpcsrvname = @distributor_rpc output,
            @distribdb = @distribution_db output,
            @publisher = @publisher

    if @@error <> 0 or @retcode <> 0 or @distribution_db is NULL
    begin
        -- "The Distributor has not been installed correctly."
        raiserror (20036, 16, -1)
        return 1
    end

    if @independent_agent = 0
    begin
        set @publication = 'ALL'
    end

    set @procedure = quotename(rtrim(@distributor_rpc)) + '.' + quotename(rtrim(@distribution_db)) + case when @action = @start then '.sys.sp_MSstartdistribution_agent' else '.sys.sp_MSstopdistribution_agent' end
    exec @retcode = @procedure
            @publisher = @publisher,
            @publisher_db = @publisher_db,
            @publication = @publication,
            @subscriber = @subscriber,
            @subscriber_db = @subscriber_db
    return @retcode
end

 
Last revision 2008RTM
See also

  sp_MSdrop_replcom (Procedure)
sp_startpushsubscription_agent (Procedure)
sp_stoppushsubscription_agent (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
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
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash