链接服务器到 Analysis Services

Linked Server to Analysis Services

在 SQL Server 2016 (13.0.1711.0) 上定义链接服务器后:

EXEC master.dbo.sp_addlinkedserver @server = N'CUBELINKEDSERVER', @srvproduct=N'MSOLAP', @provider=N'MSOLAP', @datasrc=N'POWER', @catalog=N'Model'
 /* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'CUBELINKEDSERVER',@useself=N'False',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL

并使用来自 http://www.purplefrogsystems.com/blog/2010/09/olap-cube-documentation-in-ssrs-part-1/ 的查询:

SELECT *
FROM OPENQUERY(CubeLinkedServer,
   'SELECT *
    FROM $SYSTEM.MDSCHEMA_MEASUREGROUP_DIMENSIONS') mgd
INNER JOIN OPENQUERY(CubeLinkedServer,
   'SELECT *
    FROM $SYSTEM.MDSCHEMA_MEASUREGROUPS') mg
ON mgd.XXX = mg.XXX

我收到错误:

Msg 7354, Level 16, State 1, Line 1 The OLE DB provider "MSOLAP" for linked server "CubeLinkedServer" supplied invalid metadata for column "DIMENSION_PATH". The data type is not supported.

我该如何解决?

这个thread表示不支持这种类型..

The problem is that the DIMENSION_PATH column is a complex type. If you run the DMV query in SSMS you will see that the column comes back with a + sign. If you don't particularly need that column you can just specify an explicit column list that does not include it.

SELECT a.*
FROM OPENQUERY('MSOLAP','
select
[CATALOG_NAME]
,[SCHEMA_NAME]
,[CUBE_NAME]
,[MEASUREGROUP_NAME]
,[MEASUREGROUP_CARDINALITY]
,[DIMENSION_UNIQUE_NAME]
,[DIMENSION_CARDINALITY]
,[DIMENSION_IS_VISIBLE]
,[DIMENSION_IS_FACT_DIMENSION]
--,DIMENSION_PATH
,[DIMENSION_GRANULARITY]
from
$system.MDSCHEMA_MEASUREGROUP_DIMENSIONS' ) a