Step 6: Adding and Configuring the Lookup Transformations
After you have configured the Flat File source to extract data from the source file, the next task is to define the Lookup transformations needed to obtain the values for the CurrencyKey and TimeKey. A Lookup transformation performs a lookup by joining data in the specified input column to a column in a reference dataset. The reference dataset can be an existing table or view, a new table, or the result of an SQL statement. In this tutorial, the Lookup transformation uses an OLE DB connection manager to connect to the database that contains the data that is the source of the reference dataset.
Note
You can also configure the Lookup transformation to connect to a cache that contains the reference dataset. For more information, see Lookup Transformation.
For this tutorial, you will add and configure the following two Lookup transformation components to the package:
One transformation to perform a lookup of values from the CurrencyKey column of the DimCurrency dimension table based on matching CurrencyID column values from the flat file.
One transformation to perform a lookup of values from the TimeKey column of the DimTime dimension table based on matching CurrencyDate column values from the flat file.
In both cases, the Lookup transformations will utilize the OLE DB connection manager that you previously created.
To add and configure the Lookup Currency Key transformation
In the Toolbox, expand Data Flow Transformations, and then drag Lookup onto the design surfaceof the Data Flow tab. Place Lookup directly below the Extract Sample Currency Data source.
Click the Extract Sample Currency Data flat file source and drag the green arrow onto the newly added Lookup transformation to connect the two components.
On the Data Flow design surface, click Lookup in the Lookup transformation, and change the name to Lookup Currency Key.
Double-click the Lookup CurrencyKey transformation.
On the General page, make the following selections:
Select Full cache.
In the Connection type area, select OLE DB connection manager.
On the Connection page, make the following selections:
In the OLE DB connection manager dialog box, ensure that localhost.AdventureWorksDW is displayed.
Select Use results of an SQL query, and then type or copy the following SQL statement:
select * from (select * from [dbo].[DimCurrency]) as refTable where [refTable].[CurrencyAlternateKey] = 'ARS' OR [refTable].[CurrencyAlternateKey] = 'AUD' OR [refTable].[CurrencyAlternateKey] = 'BRL' OR [refTable].[CurrencyAlternateKey] = 'CAD' OR [refTable].[CurrencyAlternateKey] = 'CNY' OR [refTable].[CurrencyAlternateKey] = 'DEM' OR [refTable].[CurrencyAlternateKey] = 'EUR' OR [refTable].[CurrencyAlternateKey] = 'FRF' OR [refTable].[CurrencyAlternateKey] = 'GBP' OR [refTable].[CurrencyAlternateKey] = 'JPY' OR [refTable].[CurrencyAlternateKey] = 'MXN' OR [refTable].[CurrencyAlternateKey] = 'SAR' OR [refTable].[CurrencyAlternateKey] = 'USD' OR [refTable].[CurrencyAlternateKey] = 'VEB'
On the Columns page, make the following selections:
In the Available Input Columns panel, drag CurrencyID to the Available Lookup Columns panel and drop it on CurrencyAlternateKey.
In the Available Lookup Columns list, select the check box to the right of CurrencyKey.
Click OK to return to the Data Flow design surface.
Right-click the Lookup Currency Key transformation, click Properties.
In the Properties window, verify that the LocaleID property is set to English (United States) and the DefaultCodePage property is set to 1252.
To add and configure the Lookup DateKey transformation
In the Toolbox, drag Lookup onto the Data Flow design surface. Place Lookup directly below the Lookup CurrencyKey transformation.
Click the Lookup Currency Key transformation and drag the green arrow onto the newly added Lookup transformation to connect the two components.
In the Input Output Selection dialog box, click Lookup Match Output in the Output list box, and then click OK.
On the Data Flow design surface, click Lookup in the newly added Lookup transformation, and change the name to Lookup DateKey.
Double-click the Lookup DateKey transformation.
On the General page, select Partial cache.
On the Connection page, make the following selections:
In the OLEDB connection manager dialog box, ensure that localhost.AdventureWorksDW is displayed.
In the Use a table or view box, type or select [dbo].[DimTime].
On the Columns page, make the following selections:
In the Available Input Columns panel, drag CurrencyDate to the Available Lookup Columns panel and drop it on FullDateAlternateKey.
In the Available Lookup Columns list, select the check box to the right of TimeKey.
On the Advanced page, review the caching options.
Click OK to return to the Data Flow design surface.
Right-click the Lookup Date Key transformation and click Properties.
In the Properties window, verify that the LocaleID property is set to English (United States) and the DefaultCodePage property is set to 1252.