Cube data can be extracted through MDX queries, we have three approaches for getting the results of an MDX query into an SSIS data stream. Out of these three approaches only last two approaches are working fine.
1. To setup a connection using the OLE DB provider for MSOLAP 9.0 and then put an MDX query in place of the SQL text. This seems to work when you Preview, but crashes SSIS when you run the job.
2. Use a linked server and an OpenQuery command. First we need to define linked server for our source catalog, then we can easily retrieve data by using open query method.
USE master
GO
/* Add new linked server */
EXEC sp_addlinkedserver
@server='LINKED_OLAP', -- local SQL name given to the linked server
@provider='MSOLAP.3', -- OLE DB provider (the .2 means the SQL2K version)
@datasrc='localhost', -- analysis server name (machine name)
@catalog='Adventure Works DW' -- default catalog/database
And then I wrapped my MDX statement in an openquery call.
Ex:
SELECT *
FROM OpenQuery (linked_olap,'SELECT --measures.members
{Measures.[Internet Sales Amount]} ON COLUMNS,
[Date].[Month].members ON ROWS
FROM [Adventure Works]')
Once we prepared this openquery then put this command in place of SQL Query. It works like a normal sql query without any errors.
3. Create a new ADO.Net Connection and from the .Net Providers\SQLClient Data Providers list choose the OLE DB Provider for AS9.0, then create a DataReader Source adapter connected to the new AS connection manager. Put the MDX into the SQLCommand property (be sure to map the external and output columns). This obviously flattens the cell set, but it doesn't limit what you put on the axes. The DataReader Source adapter turns all the columns into DT_NTEXT, which you then have to convert to DT_WSTR to be able to convert to anything else, but that's standard SSIS data type manipulation. Seems a lot slicker than creating a linked server.
Subscribe to:
Post Comments (Atom)
Hi Murty,
ReplyDeleteI know a bit of SSIS.
I would like to know the best to start learning SSAS. If you could provide me some details it would be really helpful.
Hi Sudeep,
ReplyDeleteDefinitely I will help you here. For better understanding of SSAS concepts from basics read the followig books.
"MS.Press.Microsoft.SQL.Server.2005.Analysis.Services.Step.By.Step"
"Wrox.Professional.SQL.Server.Analysis.Services.2005.with.MDX.May.2006"
You can learn from "Sql server Books online" as well. I think it is better to take AdventureWorks Samples for initial learning. It is advisable to learn MDX along with SSAS.
For learing MDX please refer : "MDX Solutions"
Thanks Murty.
ReplyDeleteI will look into this and let you know if I have any further specific query.
Always welcome Sudeep..
ReplyDelete