2012-02-06 178 views
1

我試圖確定什麼語言相當於Select getdate()是MDX。SQL Server 2008 R2的MDX GETDATE()

我想在有問題的服務器,以簡單地得到的日期,時間,實際上沒有查詢任何數據。這是一種煙霧測試,所以我需要了解我能做出的最簡單的陳述。我不想實際查詢任何多維數據集,因爲它們都有不同的結構。我只需要通過連接到服務器(不一定是數據)來獲得服務器級別的信息。

謝謝。

回答

2

報價How To Obtain the Current Day with a MDX Query or Expression in SQL Server 2000 Analysis Services

答案是:

-- The First Calculated member is the value of NOW() 
WITH MEMBER [Measures].[Full Date] as 'NOW()' 
-- The Second Calculated Member is the Day part of the first calculated member. 
MEMBER [Measures].[What Day] as 'DAY([Full Date])' 
-- The Third Calculated Member is the Month part of the first calculated member. 
MEMBER [Measures].[What Month] as 'MONTH([Full Date])' 
-- The Fourth Calculated Member is the Year part of the first calculated member. 
Member [Measures].[What Year] as 'YEAR([Full Date])' 
SELECT 
    {[Full Date],[What Day],[What Month],[What Year]} ON COLUMNS 
FROM Sales 

結果:

Full Date What Day  What Month  What Year 
1:16:16 AM 19    9    2001 

文章是社科院2000,但應與2008 R2運行。

+0

+1 - 它SSAS後的版本上運行以及2000 – Lamak 2012-02-06 20:47:41

+0

謝謝,但所有多維數據集的名稱是不同的,所以我不一定能查詢任意魔方,我只需要得到從服務器內存的東西,這就是爲什麼我使用TSQL的GetDate()函數作爲示例。謝謝。 – Snowy 2012-02-06 20:53:53

+1

你可以看到[MDX Select語句(http://msdn.microsoft.com/en-us/library/ms146002(V = SQL.90)的.aspx)比'FROM'條款是強制性的。我不知道這個條款從服務器獲取數據的方法。注意,[查詢運行完成後,使用WITH關鍵字創建的計算成員不再存在](http://msdn.microsoft.com/zh-cn/library/ms187058(v = sql.90))。 ASPX) – danihp 2012-02-06 21:04:04