1
votes

I am trying to execute this query in MDX

INSERT INTO MINING STRUCTURE [People1]
([CustID], [Name], [Gender], [Age], [CarMake],[CarModel])
OPENQUERY(Chapter3Data,
'SELECT [Key], Name, Gender, Age, CarMake, CarModel
FROM People')

I have a database Chapter3Data with people table in my SQL Server instance, but I get this error :

Executing the query ...
Either the 'Ehsan\ehsan akbar' user does not have permission to access the 'Chapter3Data' object, or the object does not exist.
Execution complete

2

2 Answers

0
votes

This is not valid mdx:

SELECT [Key], Name, Gender, Age, CarMake, CarModel
FROM People

You need to specify which axis you would like the hierarchies ON - so generally ROWS or COLUMNS - an example might be:

SELECT 
   [Key].[Key].MEMBERS ON ROWS, 
   [Gender].[Gender].MEMBERS ON COLUMS
FROM People;

In SSMS you should be able to open with a connection to the cube server - then you can open an mdx query and test your mdx to ensure it is valid - a good idea before attempting the linked server OPENQUERY function.

0
votes

The problem is that you should be linking to the name of a Data Source defined on that instance of Analysis Services, not a relational database, or the name of a linked server, or a data source view (DSV). I made all three of those mistakes before finally getting it right, after stumbling on to Raymond Li's answer to the post titled DMX INSERT Openquery Permission Problem at MSDN. It's definitely counterintuitive of Microsoft to implement it this way, since you'd plug in a database or linked server any other time you use OPENQUERY, but that's what works.