Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_scriptupdmoderefresh

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_scriptupdmoderefresh
(
    @artid int                  -- id of the article we are processing
)
as
begin
    set nocount on
    declare @retcode int
                ,@publisher sysname
                ,@subscriber sysname
                ,@subscriber_db sysname
                ,@publisher_db sysname
                ,@publication sysname
                ,@pubid int
                ,@subscription_type int
                ,@update_mode int
                ,@cmd nvarchar(4000)

    
    -- initialize
    
    select @publisher = publishingservername()
            ,@publisher_db = db_name()
    
    -- enumerate the active subscriptions for the article
    
    declare #hcsubdata cursor local fast_forward for
        select a.pubid
            ,p.name
            ,s.srvname
            ,s.dest_db
            ,s.subscription_type
            ,s.update_mode
        from ((syspublications as p join sysarticles as a
                    on p.pubid = a.pubid
                ) join syssubscriptions as s
                    on a.artid = s.artid
                    and s.status = 2
                    and s.sync_type != 2
                    and s.update_mode != 0
                )
        where s.artid = @artid
            and s.srvid <> -1 and s.srvname is not null and len(s.srvname) > 0
    for read only
    open #hcsubdata
    fetch #hcsubdata into @pubid, @publication, @subscriber, @subscriber_db, @subscription_type, @update_mode
    while (@@fetch_status = 0)
    begin
        
        -- prepare the first command to send to subscriber
        
        select @cmd = N' if exists (select * from dbo.sysobjects ' +
            N'where name = N''MSreplication_subscriptions'') begin  ' +
            N'update MSreplication_subscriptions ' +
            N'set update_mode = ' + cast(@update_mode as nvarchar(10)) +
            N' where upper(publisher) = N''' + sys.fn_replreplacesinglequote(@publisher) collate database_default + N''' and ' +
            N'publisher_db  = N''' + sys.fn_replreplacesinglequote(@publisher_db) collate database_default + N''' and ' +
            N'publication = N''' + sys.fn_replreplacesinglequote(@publication) collate database_default + N''' and ' +
            N'subscription_type = ' + cast(@subscription_type as nvarchar(10)) + N' end '
        
        -- write the first command to the log
        
        exec @retcode = sys.sp_MSadd_compensating_cmd
            @orig_srv = @subscriber
            ,@orig_db = @subscriber_db
            ,@command = @cmd
            ,@article_id = @artid
            ,@publication_id = @pubid
        if (@@error != 0 or @retcode != 0)
            return 1
        
        -- prepare the second command to send to subscriber
        
        select @cmd = N' if exists (select * from dbo.sysobjects ' +
            N'where name = N''MSsubscription_agents'') begin  ' +
            N'update MSsubscription_agents ' +
            N'set update_mode = ' + cast(@update_mode as nvarchar(10)) +
            N' ,queue_id = N''mssqlqueuev2'', queue_server = NULL ' +
            N' where upper(publisher) = N''' + sys.fn_replreplacesinglequote(@publisher) collate database_default + N''' and ' +
            N'publisher_db  = N''' + sys.fn_replreplacesinglequote(@publisher_db) collate database_default + N''' and ' +
            N'publication = N''' + sys.fn_replreplacesinglequote(@publication) collate database_default + N''' and ' +
            N'subscription_type = ' + cast(@subscription_type as nvarchar(10)) + N' end '
        
        -- write the second command to the log
        
        exec @retcode = sys.sp_MSadd_compensating_cmd
            @orig_srv = @subscriber
            ,@orig_db = @subscriber_db
            ,@command = @cmd
            ,@article_id = @artid
            ,@publication_id = @pubid
        if (@@error != 0 or @retcode != 0)
           return 1
        
        -- fetch next subscription to this article
        
        fetch #hcsubdata into @pubid, @publication, @subscriber, @subscriber_db, @subscription_type, @update_mode
    end
    close #hcsubdata
    deallocate #hcsubdata
    
    -- all done
    
    return 0
end

 
Last revision 2008RTM
See also

  sp_MSdrop_repltran (Procedure)
sp_vupgrade_updatingpublicationarticle (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