Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmerge_upgrade_from_90rtm

  No additional text.


Syntax
create procedure sys.sp_MSmerge_upgrade_from_90rtm
as
begin

    declare @count int
    declare @objectid int
    declare @tablename sysname
    declare @rowguidcol sysname
    declare @qualified_name nvarchar(517)
    declare @command nvarchar(2000)

    -- Upgrade MSmerge_past_partition_mappings index
    select @count = count(*) from sys.index_columns as ic join sys.columns as c
            on ic.object_id = c.object_id and ic.column_id = c.column_id
        join sys.indexes as si
            on ic.index_id = si.index_id and ic.object_id = si.object_id
    where si.name = 'nc2MSmerge_past_partition_mappings'

    if (@count = 1)
    begin
        -- recreate index
        drop index dbo.MSmerge_past_partition_mappings.nc2MSmerge_past_partition_mappings
        create nonclustered index nc2MSmerge_past_partition_mappings on dbo.MSmerge_past_partition_mappings (generation, tablenick) include (publication_number, partition_id)
    end

    if (object_id('sysmergesubscriptions') is not NULL)
    begin
        -- last_makegeneration_datetime
        if not exists (select * from sys.columns where object_id = object_id('dbo.sysmergesubscriptions') and
                            name = 'last_makegeneration_datetime')
        begin
            alter table dbo.sysmergesubscriptions add last_makegeneration_datetime datetime null
            if @@error <> 0 return 1
        end
    end

    -- Add index to conflict tables
    declare cft_tbl_curs cursor local fast_forward for select conflict_table from dbo.sysmergearticles
    open cft_tbl_curs
    fetch next from cft_tbl_curs into @tablename
    while (@@fetch_status <> -1)
    begin
	    if not exists (select * from sys.indexes where name = 'nc' + @tablename)
	    begin
		    select @objectid = OBJECT_ID(@tablename)
		    select @rowguidcol = name  from sys.columns where object_id = @objectid and is_rowguidcol = 1
		    if @rowguidcol is not null
		    begin
		        exec sys.sp_MSget_qualified_name @objectid, @qualified_name output
		        if @qualified_name is not null
		        begin
			        select @command = 'create nonclustered index ' + quotename('nc' + @tablename) + ' on ' + @qualified_name + ' (' + QUOTENAME(@rowguidcol) + ', origin_datasource_id)'
					exec (@command)			
			    end		
		    end
	    end
	    fetch next from cft_tbl_curs into @tablename		
    end
    close cft_tbl_curs
    deallocate cft_tbl_curs
    return 0
end

 
Last revision 2008RTM
See also

  sp_vupgrade_mergetables (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