Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading project parameters in Script Task

Tags:

ssis

ssis-2012

This is what I'm trying to do in a script task:

long lngMaxRowsToPull = Convert.ToInt64(Dts.Variables["Project::MaxRowsPerPull"].Value);

I get an error message that the variable does not exist.

Yet Its defined as a ReadOnlyVariable to the script and it does exist as a project parameter.

Its defined as a ReadOnlyVariable to the script

And it does exist as a project parameter

like image 763
Metaphor Avatar asked Dec 05 '13 21:12

Metaphor


People also ask

How do I pass parameters in script task in SSIS?

I do it like this: When opening the script task properties you have two fields, ReadOnlyVariables and ReadWriteVariables . Write your variable name into the according field based on your needs, in your case User::Variable . Show activity on this post.

How do I view parameters in SSIS?

Open the package in SQL Server Data Tools, and then click the Parameters tab in the SSIS Designer. Click the Add Parameter button on the toolbar. Enter values for the Name, Data Type, Value, Sensitive, and Required properties in the list itself or in the Properties window.

What is the use of parameters in SSIS?

Integration Services (SSIS) parameters allow you to assign values to properties within packages at the time of package execution. Parameters were introduced in SQL Server 2012. This option was added to avoid using variables and external configuration files to pass arguments on the package execution.


1 Answers

So close. ;)

Your code is trying to access a variable/parameter named Project::MaxRowsPerPull

In fact, the $ is significant so you need to reference $Project::MaxRowsPerPull

Also note that you have the data type for the parameter as Int32 but are then pushing it into Int64. You can always put a smaller type into a larger container but if you tried to fill the parameter with too large a value your package will asplode.

like image 99
billinkc Avatar answered Oct 03 '22 14:10

billinkc