Merge (MDStore Interface)

ms135491.note(zh-cn,SQL.90).gif注意:
  下一版本的 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.

ms135491.note(zh-cn,SQL.90).gif注意:
  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

请参阅

参考

MDStore Interface
UnlockObject (MDStore Interface)

帮助和信息

获取 SQL Server 2005 帮助