SQL Openquery - 对象没有列
SQL Openquery - Object has no columns
我有一个动态存储过程,它为 OpenQuery 创建一个 mdx 语句。所以 mdx 语句中的对象可能是空的。在这种情况下,我想要一个空字符串。
通常,查询有效,除非我选择一个未来的日期,在这种情况下 SQL 服务器给我这个错误:
"The OLE DB provider "XYZ" for linked server "XYZ" indicates that
either the object has no columns or the current user does not have
permissions on that object."
select
t.*
from OPENQUERY([SomeServer_OLAP],''
SELECT
non empty{[Measures].[FactWorkItemHistory Microsoft_VSTS_Scheduling_OriginalEstimate],
[Measures].[FactWorkItemHistory Microsoft_VSTS_Scheduling_CompletedWork],
[Measures].[Microsoft_VSTS_Scheduling_RemainingWork]} ON COLUMNS
, NON EMPTY { ([Work Item].[Iteration Path].[Iteration Path].ALLMEMBERS
* [Work Item].[System_AssignedTo].[System_AssignedTo].ALLMEMBERS)} on ROWS
FROM [Team System]
WHERE '+@Month+'
'') t'
因此,输入 12 月(撰写本文的月份 post)的日期参数工作正常,但输入 2018 年 1 月(下个月)和所有其他后续月份 returns 错误.感谢任何帮助。
从查询中删除 "non empty" 解决了我的问题。这似乎没有任何直接可观察到的缺点。
我有一个动态存储过程,它为 OpenQuery 创建一个 mdx 语句。所以 mdx 语句中的对象可能是空的。在这种情况下,我想要一个空字符串。
通常,查询有效,除非我选择一个未来的日期,在这种情况下 SQL 服务器给我这个错误:
"The OLE DB provider "XYZ" for linked server "XYZ" indicates that either the object has no columns or the current user does not have permissions on that object."
select
t.*
from OPENQUERY([SomeServer_OLAP],''
SELECT
non empty{[Measures].[FactWorkItemHistory Microsoft_VSTS_Scheduling_OriginalEstimate],
[Measures].[FactWorkItemHistory Microsoft_VSTS_Scheduling_CompletedWork],
[Measures].[Microsoft_VSTS_Scheduling_RemainingWork]} ON COLUMNS
, NON EMPTY { ([Work Item].[Iteration Path].[Iteration Path].ALLMEMBERS
* [Work Item].[System_AssignedTo].[System_AssignedTo].ALLMEMBERS)} on ROWS
FROM [Team System]
WHERE '+@Month+'
'') t'
因此,输入 12 月(撰写本文的月份 post)的日期参数工作正常,但输入 2018 年 1 月(下个月)和所有其他后续月份 returns 错误.感谢任何帮助。
从查询中删除 "non empty" 解决了我的问题。这似乎没有任何直接可观察到的缺点。