編號:Grouping SSAS members into buckets using MDX與執行MDX WITH子句中的T-SQL中引發錯誤
感謝您與有關分組SSAS成員到使用MDX水桶問題的幫助。當在SSAS中獨立運行或直接在SSMS中運行時,它可以很好地工作。
然而,我試圖包相同的一個T-SQL過程中使用下面的記錄插入表,執行失敗的錯誤消息:
declare @query nvarchar(4500)
set @query = 'insert into ssas_results
select * from OPENQUERY(ssaslink,''
select * from
(
WITH
SET [RestOfWorld] AS
{
[Customer].[Customer Geography].[Country].&[United Kingdom]
,[Customer].[Customer Geography].[Country].&[Germany]
}
MEMBER [Customer].[Customer Geography].[All].[RestOfWorld] AS
Aggregate
(
{
[Customer].[Customer Geography].[Country].&[United Kingdom]
,[Customer].[Customer Geography].[Country].&[Germany]
}
)
SET [CountriesMinusROW] AS
[Customer].[Customer Geography].[Country].MEMBERS - [RestOfWorld]
SELECT
NON EMPTY
{[Measures].[Internet Sales Amount]} ON 0
,NON EMPTY
[Product].[Category].[Category]
*
{
[CountriesMinusROW]
,[Customer].[Customer Geography].[All].[RestOfWorld]
} ON 1
FROM [Adventure Works]
WHERE
[Date].[Calendar Year].&[2007])'') AS SSASREC'
exec (@query)
When I executed the stored procedure, I get the error message:
OLE DB provider "MSOLAP" for linked server "ssaslink" returned message "Subselects and subcubes cannot define new calculations using the WITH clause.".
消息7321,級別16,國家2,2號線 時發生錯誤,準備查詢「
是這種方法在SSAS不支持?什麼是我可以使用存儲過程插入查詢到表的結果的最佳方式是什麼?
謝謝whytheq和SouravA的迴應。我必須將它包裝在T-SQL過程中,因爲日期和其他一些字段是可變的,並插入表中以進行其他一些計算。儘管最初我嘗試過 - 將MDX直接放在引號內並得到相同的錯誤。會再次給它一次 - 也許我第一次沒有做對。 – Bee
@Bee - 檢查我的編輯。 – SouravA
提高了,指出了一點。我幾乎沒有'OPENQUERY'的經驗。你的建議是有效的。 – SouravA