在SSAS多维数据集中更新度量

时间:2014-10-21 21:47:36

标签: sql ssas mdx cube

除了修改和重新运行整个CREATE XMLA多维数据集脚本之外,有没有办法在SSAS(SQL Server Analysis Server)多维数据集中创建新度量?

尝试了以下独立的MDX查询:

查询#1

CREATE MEMBER CURRENTCUBE.Measures.[TestMeasure] AS 
NULL;

结果:

Executing the query ...
No cube specified. A cube must be specified for this command to work.
Execution complete

查询#2

CREATE MEMBER [CubeName].Measures.[TestMeasure] AS 
NULL;

结果:

Executing the query ...
Execution complete

注意:查询#2会执行,但测量不会出现在" CubeName"立方体。

1 个答案:

答案 0 :(得分:2)

CREATE MEMBER是作用域的,因此这些成员不会在您的会话/查询之外持久存在。

要在CUBE上创建新的永久计算成员,您需要使用ALTER XMLA脚本,而不是CREATE XMLA脚本。

一个例子,无耻地从网上偷窃:

<Alter AllowCreate="true" ObjectExpansion="ExpandFull" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
  <Object>
    <DatabaseID>CVCC</DatabaseID>
    <CubeID>CVCC</CubeID>
    <MdxScriptID>MDXScript</MdxScriptID>
  </Object>
  <ObjectDefinition>
    <MdxScript>
      <ID>MDXScript</ID> 
      <Name>MDXScript</Name>
      <Commands>
        <Command>
          <Text> <!–if you want to figure out what to paste below build the calculation in visual studio then look at the ‘script view’–>
            CALCULATE;
            CREATE MEMBER CURRENTCUBE.[MEASURES].[TestMeasure]
            AS **Your calc goes here**;
          </Text>
        </Command>
      </Commands>
    </MdxScript>
  </ObjectDefinition>
</Alter>