Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSreset_subscription

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_MSreset_subscription
(
    @publisher sysname,
    @publisher_db sysname,
    @publication sysname,
    @subscriber sysname,
    @subscriber_db sysname,
    @subscription_type int  -- have to have it to identify a distribution agent.
)
AS
begin
    SET NOCOUNT ON

    /*
    ** Declarations.
    */
    DECLARE @retcode            int
    DECLARE @publisher_id       smallint
    DECLARE @subscriber_id      smallint
    DECLARE @virtual            smallint
    DECLARE @virtual_anonymous  smallint
	declare @anonymous_subtype  smallint
	declare @publication_id		int
	declare @immediate_sync		bit

    
    -- security check
    -- only db_owner can execute this
    
    if (is_member ('db_owner') != 1)
    begin
        raiserror(14260, 16, -1)
        return (1)
    end

    /*
    ** Initializations
    */
    select @virtual = -1
    select @virtual_anonymous = -2
    select @anonymous_subtype = 2

    select @publisher_id = srvid from master.dbo.sysservers where
        UPPER(srvname) = UPPER(@publisher)

    select @subscriber_id = srvid from master.dbo.sysservers where
        UPPER(srvname) = UPPER(@subscriber)

	select @publication_id = publication_id, @immediate_sync = immediate_sync
		from dbo.MSpublications where
        publisher_id = @publisher_id AND
        publisher_db = @publisher_db AND
        publication = @publication

    if @subscriber is NULL
        select @subscriber_id = @virtual

	-- No need to have 2 updates in one transaction.
	if @immediate_sync = 1
	begin
		UPDATE MSdistribution_agents SET subscription_guid = newid()
			WHERE
			publisher_id = @publisher_id AND
			publisher_db = @publisher_db AND
			publication = @publication and
			subscriber_id = @subscriber_id and
			subscriber_db = @subscriber_db and
			subscription_type = @subscription_type

		IF @@ERROR <> 0
			GOTO UNDO

        if @subscriber_id = @virtual
        begin
            -- reset the partial snapshot progress of all anonymous
            -- agents associated with this virtual subscription

            update dbo.MSdistribution_agents
               set reset_partial_snapshot_progress = 1
			 where
			publisher_id = @publisher_id AND
			publisher_db = @publisher_db AND
			publication = @publication and
			subscriber_id <> @virtual and
            subscriber_id <> @virtual_anonymous and
			subscription_type = @anonymous_subtype
        end
	end

	UPDATE dbo.MSsubscriptions set subscription_time = getdate()
        WHERE
        publisher_id = @publisher_id AND
        publisher_db = @publisher_db AND
        publication_id = @publication_id and
        subscriber_id = @subscriber_id and
        subscriber_db = @subscriber_db and
        subscription_type = @subscription_type

    IF @@ERROR <> 0
        GOTO UNDO

    RETURN(0)

UNDO:
    return(1)
end

 
Last revision 2008RTM
See also

  sp_instdist (Procedure)
sp_MSrepl_reinitsubscription (Procedure)
sp_MSreset_subscription_seqno (Procedure)
sp_MSupdate_subscription (Procedure)
sp_replmonitorsubscriptionpendingcmds (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