Getting Started with ASP.NET MVC - Part 5: How to do programming with razor syntax
First Time? You can support us by signing up. It takes only 5 seconds. Click here to sign up. If you already have an account, click here to login.


Upload Image Close it
Select File

Browse by Tags · View All
#SQLServer 46
SQL Server 44
SSRS EXPERT 41
BI 36
#BI 33
brh 28
SSIS BEST PRACTICES 23
TSQL 19
MS BI STACKS 18
SSRS 17

Archive · View All
March 2011 24
July 2011 17
February 2011 15
April 2010 13
June 2011 11
May 2011 11
April 2011 11
July 2010 11
March 2010 8
December 2011 7

SSIS #101 – Use expressions to pass parameters to ADO.NET Source

Sep 30 2011 12:18PM by Sherry Li   

I have several posts on how to pass parameters to

1) an OLE DB source in a data flow and

2) to an Execute SQL Task with OLE DB connection.

For case 2), the key is to use the correct mark for the passed in parameter. Different connection types demand different ways to mark the parameters.

For case 1), changing the OLE DB source to an ADO.NET source in the data flow will change the game completely.

The familiar button Parameters… will disappear if the data flow source is an ADO.NET source.

You feel deflated when you don’t see the Parameters… button. But hold on.. There is actually a very elegant way in SSIS to pass variables to queries. As a matter of fact, a more generic way. That is to use expressions with the variables embedded.

To use expressions for an ADO.NET source in a data flow, here are a few simple steps:

Step 1 – Go to the Data Flow Task Properties window

On the Control Flow tab (not the Data Flow tab), right-click the Data Flow Task you are working on and select Properties.

Step 2 – Open the Property Expression Editor

In the Properties window, find a property called Expression and a small button next to it. Click the button to open the Expression Editor.


Step 3 – Open the Expression Builder for SQL Command

In the Property list, select [ADO NET Source].[SqlComamnd] and click the button next to the Expression column to open Expression Builder.

Step 4 – Write query with variables

Start to write your query with variable names and click the Evaluate Expression button to test the expression.

My simple example:

SELECT * FROM T_COMPLETE_ACCOUNT 
WHERE ACCOUNT_ID = ’" + @[User::varACCOUNTID] + "’

Save your package and test it. This is it.

You might ask why I said this is a more generic way. It is because you can use expressions with variables for not just ADO.NET data flow source, you can use expressions to work with almost any SSIS data elements. But the question is, how often do I use expressions in my queries. Not very often, I have to say. The reason is that the expressions can get out of control very quickly when my queries become more and more complex. I just simply don’t want to look at my queries and not be able to tell what it does in one glance.

Anyway, this should get your opinion about SSIS back on track. It is a wonderful tool after all.

Tags: SSIS BEST PRACTICES, #SQLServer, SQL Server, BI, #BI,


Sherry Li
11 · 15% · 3274
3
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

2  Comments  

  • Amazing

    commented on Oct 18 2011 1:22AM  .  Report Abuse This post is not formatted correctly
    Alpesh Patel
    45 · 5% · 1023
  • Great post! I'm working on doing something like this against a TeraData source. After defining my query, how do I produce a valid column list? Available External Columns is empty?

    Thanks, Alex

    commented on Mar 9 2012 12:43PM  .  Report Abuse This post is not formatted correctly
    Alex
    2165 · 0% · 3

Your Comment


Sign Up or Login to post a comment.

"SSIS #101 – Use expressions to pass parameters to ADO.NET Source" rated 5 out of 5 by 3 readers
SSIS #101 – Use expressions to pass parameters to ADO.NET Source , 5.0 out of 5 based on 3 ratings
    Copyright © Beyondrelational.com Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising