共用方式為


Merge (MDStore Interface)

[!附註]

  下一版的 Microsoft SQL Server 將不再提供此功能。請勿在新的開發工作中使用此功能,並且儘速修改使用此功能的應用程式。

The Merge method of the MDStore interface merges two partitions into a single partition. The partitions must have the same aggregations and storage modes.

Applies To:clsPartition

語法

object.Merge(ByVal SourceName As String)

參數

  • object
    The partition object into which to merge the source partition object.

  • SourceName
    A string that contains the name of the source partition object.

備註

Before merging two partitions that specify data slices, you must first set the slice of the receiving partition to the slice that will apply after the merge has been completed. Otherwise, the partitions will not be successfully merged. The slice for the receiving partition must be the parent of the first level, where the slice values for the two partitions differ.

For example, if you are merging a partition that contains data based on the slice [AllTime].[1998].[Quarter2] into a partition that contains [AllTime].[1998].[Quarter1], the target partition's slice must be set to the parent of the two slices that differ, in this case [AllTime].[1998]. The target partition's slice must be set to this value before merging the partitions. For more information, see Managing Partitions and Merging Partitions.

[!附註]

  This adjustment is done automatically when you merge partitions using the Analysis Manager user interface.

Examples

The following code prepares two partitions for a merge by merging the data slice values so they are equal:

Sub MergeDataSlices(SourcePart As DSO.MDStore, _
    TargetPart As DSO.MDStore)
    ' This example code merges the data slices of two partitions.
    ' This subroutine does not merge the partitions; instead,
    ' it compares the source and target partitions, changing
    ' the target partition to match the source partition to
    ' prepare it for merging.
    
    Dim dsoDimSource As DSO.Dimension
    Dim dsoLevelSource As DSO.Level
    Dim dsoDimTarget As DSO.Dimension
    Dim dsoLevelTarget As DSO.Level
    
    Dim nDim As Integer, nLev As Integer, nLev2 As Integer
    
    ' Search for the first level where the slice differs.
    ' Then use the parent level just above it.
    ' Loop through each dimension in the source partition.
    For nDim = 1 To SourcePart.Dimensions.Count
        Set dsoDimSource = SourcePart.Dimensions(nDim)
        Set dsoDimTarget = TargetPart.Dimensions(nDim)
        
        ' For each source and target dimension, compare the two
        ' and find the first level where the data slice differs.
        For nLev = 1 To dsoDimSource.Levels.Count
            Set dsoLevelSource = dsoDimSource.Levels(nLev)
            Set dsoLevelTarget = dsoDimTarget.Levels(nLev)
            
            If dsoLevelSource.SliceValue <> dsoLevelTarget.SliceValue Then
            
                ' Clear the slice values for all of the levels below
                ' in the target partition.
                For nLev2 = nLev To dsoDimSource.Levels.Count
                    Set dsoLevelTarget = dsoDimTarget.Levels(nLev2)
                    dsoLevelTarget.SliceValue = ""
                Next
            
                ' Stop looping through levels.
                Exit For
            
            End If
        Next
    Next
    
    ' Now that the target partition is ready for merge,
    ' update it.
    TargetPart.Update
End Sub