2012-02-06 179 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