MDX + TSQL列名称不存在

时间:2014-04-08 09:10:26

标签: sql-server tsql mdx data-warehouse

我必须创建MDX和TSQL的混合,如下所示:

    select "[State].[Country].[Country].[MEMBER_CAPTION]" as State,
    "[Measures].[someMeasure]" as [Sum]
    from openquery(my_olap_server,
    'select [Measures].[someMeasure] on 0,
    filter([State].[Country].[Country],not isempty([Measures].[someMeasure])) on 1
    from (select {[State].[Country].[Country].&[index_here]} on columns from [My Cube])')

如果MDX没有返回值,则[State].[Country].[Country].[MEMBER_CAPTION]不存在,因此查询失败并显示消息

Msg 207, Level 16, State 1, Line 2
Invalid column name '[State].[Country].[Country].[MEMBER_CAPTION]'

有没有办法强制MDX或TSQL(但我猜测MDX)提供这个? 感谢

1 个答案:

答案 0 :(得分:1)

    select "[Measures].[StateName]" as State,
    "[Measures].[someMeasure]" as [Sum]
    from openquery(my_olap_server,
    'with member [Measures].[StateName]
    as [State].[Country].CURRENTMEMBER.MEMBER_CAPTION
    select {[Measures].[StateName],[Measures].[someMeasure]} on 0,
    filter([State].[Country].[Country],not isempty([Measures].[someMeasure])) on 1
    from (select {[State].[Country].[Country].&[index_here]} on columns from [My Cube])')

是解决方案。很简单:)