SSIS 2011 Denali Expression Task

Posted by on Jul 13, 2011 in SQL Server, SSIS | No Comments

SSIS Denali 2011 CTP 3 released at 12 July 2011, you can get it from here,

If you try SSIS Denali you will see a new task in Control flow, named Expression Task.

In this post I’ll talk about the Expression Task;

Expression Task created to do assignment on package variables or parameters.

you can write any expression you want there and assign it to any variable or parameter.

for example this is sample expression :

@[User::PreviousMonth]= MONTH( DATEADD( "MM", -1, GETDATE()  )  )

This will assign previous month number to the PreviousMonth variable.

If you experienced previous version of SSIS, you remember that you can do same thing with resort of expression property of variables and set EvaluateAsExpression of that property to true.

So what is difference between Expression Task and previous method?

Actually the previous method is still working and you can use it, and Expression task didn’t do any new thing. But the operation of assigning an expression result to a variable was not isolated in a TASK, the Expression Tasks comes to perform this as a TASK.

this is sample of Expression Task usage:

create a package first, add Expression task from toolbox

also add a package variable of type Int32 in package scope, and name it as PreviousMonth,

then go to expression task editor, and write this expression there:

@[User::PreviousMonth]= MONTH( DATEADD( "MM", -1, GETDATE()  )  )

then add a breakpoint to PostExecute event of expression Task,

and run the package, now when package pause at breakpoint you can see the PreviousMonth variable value in the watch window

That’s It.

Reza Rad
Reza Rad is an Author, Trainer, Speaker and DW/BI Consultant. He has a BSc in Computer engineering; he has more than 15 years’ experience in databases, programming and development mostly on Microsoft technologies. He is a Microsoft MVP in Data Platform for seven continues years (from 2011 till now) for his dedication in Microsoft BI. He is author of some SQL Server and BI books, and also Power BI online book; from Rookie to Rock Star.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">