dbTalk Databases Forums  

Aliasing columns in MDX query

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Aliasing columns in MDX query in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DM
 
Posts: n/a

Default Aliasing columns in MDX query - 11-17-2006 , 06:48 AM






I am new to MDX. I use the following query in SQL server to pull data from an
Analysis Service DB using a linked server. The new table created has column
names with square braces. I would like to rename the columns when data is
fetched.


select * into MyData from OPENQUERY(AS_LINK,
'
SELECT
{ [Measures].[sales amount], [Measures].[tax amt] } ON 0,
non empty nest([order date].[calendaryear].[2001],[order
date].[englishmonthname].Members ) ON 1
FROM [astutorial]
where ([product].[model name].members)
')


Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: Aliasing columns in MDX query - 11-19-2006 , 05:04 AM






It is easiest to do this in the outer SQL query
eg.


select
[[Measures].[sales amount]] as Sales
[[Measures].[tax amt]] as Tax

...

into MyData from OPENQUERY(AS_LINK,
'
SELECT
{ [Measures].[sales amount], [Measures].[tax amt] } ON 0,
non empty nest([order date].[calendaryear].[2001],[order
date].[englishmonthname].Members ) ON 1
FROM [astutorial]
where ([product].[model name].members)
')


--
Regards
Darren Gosbell - SQL Server MVP
Blog: http://www.geekswithblogs.net/darrengosbell

In article <E719D31D-5DFE-4DA0-BBF8-B17ACE6E8D93 (AT) microsoft (DOT) com>,
DM (AT) discussions (DOT) microsoft.com says...
Quote:
I am new to MDX. I use the following query in SQL server to pull data from an
Analysis Service DB using a linked server. The new table created has column
names with square braces. I would like to rename the columns when data is
fetched.


select * into MyData from OPENQUERY(AS_LINK,
'
SELECT
{ [Measures].[sales amount], [Measures].[tax amt] } ON 0,
non empty nest([order date].[calendaryear].[2001],[order
date].[englishmonthname].Members ) ON 1
FROM [astutorial]
where ([product].[model name].members)
')



Reply With Quote
  #3  
Old   
DM
 
Posts: n/a

Default Re: Aliasing columns in MDX query - 11-20-2006 , 12:07 AM



Thanks for the suggestion.

A slight variation of what you have suggested worked. When there is a ']' as
part of the column name it need to be prefixed with another ']' as given the
query below.

select
[[Measures]].[Sales Amount]]] as Sales,
[[Measures]].[Tax Amt]]] as Tax
into #ttt from OPENQUERY(AS_LINK,
'SELECT
{ [Measures].[sales amount], [Measures].[tax amt] } ON 0,
non empty nest([order date].[calendaryear].[2001],[order
date].[englishmonthname].Members ) ON 1
FROM [astutorial]
where ([product].[model name].members)
')



"Darren Gosbell" wrote:

Quote:
It is easiest to do this in the outer SQL query
eg.


select
[[Measures].[sales amount]] as Sales
[[Measures].[tax amt]] as Tax

...

into MyData from OPENQUERY(AS_LINK,
'
SELECT
{ [Measures].[sales amount], [Measures].[tax amt] } ON 0,
non empty nest([order date].[calendaryear].[2001],[order
date].[englishmonthname].Members ) ON 1
FROM [astutorial]
where ([product].[model name].members)
')


--
Regards
Darren Gosbell - SQL Server MVP
Blog: http://www.geekswithblogs.net/darrengosbell

In article <E719D31D-5DFE-4DA0-BBF8-B17ACE6E8D93 (AT) microsoft (DOT) com>,
DM (AT) discussions (DOT) microsoft.com says...
I am new to MDX. I use the following query in SQL server to pull data from an
Analysis Service DB using a linked server. The new table created has column
names with square braces. I would like to rename the columns when data is
fetched.


select * into MyData from OPENQUERY(AS_LINK,
'
SELECT
{ [Measures].[sales amount], [Measures].[tax amt] } ON 0,
non empty nest([order date].[calendaryear].[2001],[order
date].[englishmonthname].Members ) ON 1
FROM [astutorial]
where ([product].[model name].members)
')




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.