Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to select from a column name gen by MDX?

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-11 : 15:30:09
Hi,

I created a SQL table from an MDX query through openquery command.

The table that gets created uses the dimension reference names in MDX for Columns names.

So, when I try to select, it gives an error.

Here is my select statement:
Select [[IP Address].[Domain Names].[Domain Name].[MEMBER_NAME]]
From CubeDomains


Here's the error I get:
Unclosed quotation mark after the character string 'MEMBER_NAME]
From CubeDomains

--PhB

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-11 : 15:39:09
Delete the outer brackets.
Select [[IP Address].[Domain Names].[Domain Name].[MEMBER_NAME]]



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-11 : 15:42:07
Thanks for the quick reply.

I tried that and this is what i get:
The multi-part identifier "IP Address.Domain Names.Domain Name.MEMBER_NAME" could not be bound.

--PhB
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-11 : 15:54:49
Can you show the complete select statement and the table structure?

In T-SQL an object (i.e. table) can be:
servername.databasename.schema.tablename

While I am answering I think you have a table CubeDomains with columns
[IP Address]
[Domain Names]
[Domain Name]
[MEMBER_NAME]

So your select should be
select
[IP Address],
[Domain Names],
[Domain Name],
[MEMBER_NAME]
from CubeDomains



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-11 : 16:08:53
The table has one column and that is the full name of the column:
[IP Address].[Domain Names].[Domain Name].[MEMBER_NAME]

Like I say above this column name is generated by the output of the MDX query.

The select statement is the one I posted above.

--PhB
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-11 : 16:11:40
Then try to use ONLY the outer brackets and delete the others.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-11 : 16:24:06
Tried that too:
Invalid column name 'IP Address.Domain Names.Domain Name.MEMBER_NAME'.

Thanks for your help.

--PhB
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-11 : 16:30:54
So sorry for that.
But now I have tested it.
This shouild really work:

select
"[IP Address].[Domain Names].[Domain Name].[MEMBER_NAME]"
from CubeDomains

" = double quote (not 2 single quotes!)



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2010-01-11 : 16:36:35
That worked!

You're beautiful!!


--PhB
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-11 : 17:07:50
No problem. Thanks for being patient.
Usually it is not my way to say try this, try that and so on...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -