Tải bản đầy đủ - 0 (trang)
7-28. Exporting an SSAS Dimension Using SSIS

7-28. Exporting an SSAS Dimension Using SSIS

Tải bản đầy đủ - 0trang

Chapter 7 ■ Exporting Data from SQL Server



Solution

Use SSIS to connect to an SSAS cube and export the data. I’ll explain how.

1.



Create a new SSIS package. Add an OLEDB connection manager named OLAP_

Source, configured as follows:

OLEDB Provider:



Microsoft OLEDB Provider for Analysis Services 11.0



Server or File Name:



localhost (or your SSAS instance, if on another box)



Initial Catalog:



CarSales_OLAP (for my examples—use your SSAS

database for your data).



2.



Add a new Flat file destination. Name it SSASOutFlatFile and specify the file location.

Check the Unicode box and check “Column names in the first row”.



3.



Go to the Advanced pane and add four new columns. Define the types as follows:



Name



DataType



OutputColumnWidth



ID



Four byte signed integer



ClientName



string [DT_STR]



ClientSize



Four byte signed integer



WholesaleRetail



string [DT_STR]



50



20



4.



Confirm your modifications with OK.



5.



Add a Data Flow task. Double-click to edit.



6.



In the Data Flow pane, add an OLEDB source. Configure as follows:



7.



OLEDB Connection Manager:



OLAP_Source



Data Access Mode:



Table or View



Name of Table or View:



[Car Sales DW].[$Dim clients]



Click Columns and alias all the Output Columns to simpler names without square

brackets or spaces, as shown in Figure 7-28.



414

www.it-ebooks.info



Chapter 7 ■ Exporting Data from SQL Server



Figure 7-28.  Renaming the column output from SSAS



8.



Confirm your modifications with OK.



9.



Add a Flat File destination. Connect the Copy Column task to it. It should default to

using the SSASOutFlatFile connection manager —if not, select it. Click Mappings and

ensure that the copied columns only are mapped to the destination columns.



10.



Confirm your modifications with OK.



How It Works

As if to prove its credentials as an excellent all-round data transfer tool, SSIS can export data from Analysis

Services too. What is more, it can export to any standard Data Flow destination. In fact, SSAS is so similar to

any other OLEDB or ADO.NET data source that there is very little unusual to remark. The exceptions are that a

dimensional data source is very different from a relational or flat file source, and that some careful MDX querying

may be required to output the exact data you want in the form that SSIS can process.



415

www.it-ebooks.info



Chapter 7 ■ Exporting Data from SQL Server



As an introduction to SSIS for SSAS, it is probably easiest to start with a simple dimension extract.

A dimension in SSAS, after all, closely resembles a relational table. Here we exported as a flat file—but you can

export to any SSIS destination.



Hints, Tips, and Traps





You should use the Analysis Services provider that is installed on your server. The version

will correspond to the installed version(s) of SSAS.







If you are using an older version of SSIS and exporting data to a relational table, you will

have to take care in specifying the destination columns, and more particularly, the data

types, since SSAS does not provide sufficient information to allow a destination component

to create tables perfectly—which a warning dialog box will state (see Figure 7-29).



Figure 7-29.  Data type warning in SSAS 2005/2008





You will probably always be better off to think through the destination table first, and

then create it in the destination server before creating the SSIS package. In this particular

example, the DDL is:

CREATE TABLE SSASExport

(

[ID] INT,

[Client Name] NVARCHAR(50),

[Client Size] INT,

[Wholesale Retail] NVARCHAR(20)

);

GO



7-29. Exporting the Result of an MDX Query in SSIS

Problem

You want to transfer tabular SSAS data into an SQL Server table using a complex MDX query on a regular basis.



416

www.it-ebooks.info



Chapter 7 ■ Exporting Data from SQL Server



Solution

Use an SSIS data flow task to export the data. I’ll show you how.

1.



Create a destination table called CubeOutput already set up to hold the source data,

created as follows (C:\SQL2012DIRecipes\CH07\tblCubeOutput.sql):

CREATE TABLE CarSales_Staging.dbo.CubeOutput

(

ClientName NVARCHAR(250),

SalePrice NVARCHAR (250),

CostPrice NVARCHAR (250)

);

GO



2.



Create a new SSIS package. Add an ADO.NET connection manager named

OLAP_Source, configured as follows:

ADO.NET Provider:



.NET Providers for OLEDB \Microsoft OLEDB

Provider for Analysis Services 11.0



Server or File Name:



localhost (or your SSAS instance, if on another box)



Initial Catalog:



CarSales_OLAP (for my examples—use your

SSAS database for your data).



3.



Click All on the left of the dialog box, scroll up to Extended Properties, and enter

FORMAT = TABULAR.



4.



Add an OLEDB connection manager named OLEDB_Destination, configured as

follows:

OLEDB Provider:



SQL Server Native Client 11.0



Server or File Name:



ADAM02 (Substitute with your SQL Instance)



Initial Catalog:



CarSales (or your database)



417

www.it-ebooks.info



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

7-28. Exporting an SSAS Dimension Using SSIS

Tải bản đầy đủ ngay(0 tr)

×