There are only a few steps and involve the use of an expression. Listed below is an example using an Execute SQL Task. Note that I'm applying SQL Server 2008 R2 with BIDS. Later version may differ somewhat.
Steps:
- Create a new user variable called "SQLTask" with a Scope of "Package", Data Type "String" and a value of "SQL - Process Employee SQL". (It is a good idea to name your control and data flow tasks clearly. You'll be grateful later when troubleshooting.)
- Add an Execute SQL Task into the Control Flow. Double-click on it to view the Execute SQL Task Editor.
- On the left side of the Editor window, select Expressions. When you do so you'll see "Misc" with Expressions appearing on the next line underneath.
- Select Expressions under Misc and then select the small browse button icon when it appears. This should open the "Property Expression Editor" window.
- The Property Expression Editor will show two columns, Property and Expression. Select the empty box under Property and select the drop-down when it appears. Scroll down until you find "Name" and select it.
- In the right-column under Expression, select the empty box to the right of Name and then select the small browse button when it appears. This will open the Expression builder window.
- In the Expression builder window there will be two list areas at the top, with the one on the right showing "Variables". Open the Variables folder, which should then list mostly System variables. But the one just created will be prefaced with "User" called "User:SQLTask". Drag it into the Expression box below.
- Select the "Evaluate Expression button". Doing so should now show "SQL - Process Employee SQL" in the grayed-out "Evaluate value" box. It confirms that it is correctly picking up the variable value.
- Select the OK button in the Expression Builder window.
- Select the OK button in the Property Expression Editor window.
- And select the OK button in the Execute SQL Task Editor window.
While the task name from the variable does not get captured when viewed in the Control/Data flow, it will show up when a failure takes place. But because of this, it would still be a good idea to use clear task names in your SSIS package for yourself and others who need to understand the logic/decisions in the process.
On that note, I always recommend a good consistent naming convention for control and data flow tasks beginning with the recommendations discussed in the following link.
Suggested Best Practices and naming conventions
Hope this helps.