Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_vupgrade_publisher

  No additional text.


Syntax

create procedure sys.sp_vupgrade_publisher @ver_old int, @ver_retention int
as
begin

    set nocount on

    declare @proc_name            nvarchar(350)
    declare @publication        sysname
    declare @upgraded            bit
    declare @retcode             int
    declare @publisher_db        nvarchar(270)
    declare @agentname            sysname
    declare @has_dbaccess        bit
    declare @nonsqlsub          sysname

    -- raiserror('sp_vupgrade_publisher', 0,1)

    /*
     * Set the master.sysservers.nonsqlsub bit for all rows with srvproduct='MSREPL-NONSQL'
    */
    declare hCNonSQLSub cursor local FAST_FORWARD for
        select srvname from master.dbo.sysservers
         where srvproduct=N'MSREPL-NONSQL'
    open hCNonSQLSub
    fetch hCNonSQLSub into @nonsqlsub
    while (@@fetch_status <> -1)
    begin
        exec @retcode = sys.sp_serveroption @server = @nonsqlsub,
                                            @optname = 'nonsqlsub',
                                            @optvalue = 'true'
        if @retcode <> 0 or @@error <> 0
        begin
            close hCNonSQLSub
            deallocate hCNonSQLSub
            return 1
        end
        fetch hCNonSQLSub into @nonsqlsub
    end
    close hCNonSQLSub
    deallocate hCNonSQLSub

    /*
     * Expired subscription cleanup agent name needs set to localized string (message 20569) and
     * jobstep set to correct procedure name based on name change between SQL7.0 and SQL7.5
    */
    set @agentname = formatmessage(20569)

    update msdb.dbo.sysjobs
        set name = @agentname
        from msdb.dbo.sysjobs, msdb.dbo.sysjobsteps as s
        where msdb.dbo.sysjobs.job_id = s.job_id
        and
        ( upper(s.command) = upper(N'EXEC sp_MScleanup_subscription')
        or upper(s.command) = upper(N'EXEC dbo.sp_MScleanup_subscription')
        or upper(s.command) = upper(N'EXEC sys.sp_MScleanup_subscription'))

    update msdb.dbo.sysjobsteps
        set  command = N'EXEC dbo.sp_expired_subscription_cleanup'
        where upper(command) = upper(N'EXEC sp_MScleanup_subscription')
        or upper(command) = upper(N'EXEC dbo.sp_MScleanup_subscription')
        or upper(command) = upper(N'EXEC sys.sp_MScleanup_subscription')

    
    -- Process schema and metadata changes for each publishing database on the publisher.
    
    -- Transactional replication system tables at the publisher are updated by sp_vupgrade_publisherdb.
    -- Most merge system tables exist in both the publishing and subscribing databases; merge schema
    -- and metadata changes are processed by a separate pass over all databases in sp_vupgrade_mergetables.
    
    -- Upgrade all databases except system and distribution db's
    -- These db's cannot be publisher databases
    DECLARE #DC CURSOR LOCAL FAST_FORWARD
    FOR
    SELECT  distinct N'[' + replace(name, N']', N']]') + N']',
            has_dbaccess(name)
    FROM    master.dbo.sysdatabases
    -- where ((category & 4) = 4) or ((category & 1) = 1)
    WHERE   name NOT IN
                (
                    N'master' COLLATE DATABASE_DEFAULT,
                    N'tempdb' COLLATE DATABASE_DEFAULT,
                    N'msdb'   COLLATE DATABASE_DEFAULT,
                    N'model'   COLLATE DATABASE_DEFAULT
                )
			AND   sys.fn_MSrepl_isdistdb (name) = 0
			and databasepropertyex(name, 'Updateability') = 'READ_WRITE'

    FOR READ ONLY

    open #DC
    fetch #DC into @publisher_db, @has_dbaccess
    while (@@fetch_status <> -1)
    begin
        -- upgrade repl tables in publishing dbs if needed
        -- skip any database in an offline state and write warning to upgrade log
        if ( @has_dbaccess = 1 )
        begin
            raiserror( 21375, 10, 1, @publisher_db) with nowait

            select @proc_name = @publisher_db + '.sys.sp_refreshreplsysservers'
            exec @retcode = @proc_name @mode = 1 -- mode 1 means don't error out if sysreplservers contains a row pointing to remote server
            if @retcode<>0 or @@ERROR<>0
            begin
                return (1)
            end

            select @proc_name = @publisher_db + '.sys.sp_vupgrade_publisherdb'
            exec @retcode = @proc_name
                @ver_old = @ver_old,
                @ver_retention = @ver_retention
            if @retcode<>0 or @@ERROR<>0
            begin
                return (1)
            end

        end
        else
        begin
            raiserror( 21376, 10, 1, @publisher_db) with nowait
        end

        fetch #DC into @publisher_db, @has_dbaccess

    end
    close #DC
    deallocate #DC

    /*
     * We need to mark sp_MScleanupmergepublisher as a startup procedure
     * if there are any databases enabled for merge replication.
     */
    if exists (select * from master.dbo.sysdatabases where (category & 4) <> 0)
    begin
        exec ('use master
               exec sys.sp_procoption ''sp_MScleanupmergepublisher'', ''startup'', ''true''')
    end

end

 
Last revision 2008RTM
See also

  sp_MSrestoredbreplication (Procedure)
sp_vupgrade_distdb (Procedure)
sp_vupgrade_publisherdb (Procedure)
sp_vupgrade_replication (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