Reputation: 561
I'm trying to execute a sql script using the task in SSIS.
My script just inserts a bunch of nambe value pairs in a table. For example -
insert into mytable (name, value) values (?, 'value1'), (?, 'value2')
Now, I want to map a variable defined in SSIS to be mapped to the parameters in the statement above. I tried defining a scalar variable but I guess the sql task doesn't like that. Oh and all the name parameters in the insert statement resolve to a single variable.
For example I want insert into mytable (name, value) values ('name1', 'value1'), ('name1', 'value2')
When I open the Parameter Mapping tab for the task, it wants me to map each parameter invidually like -
Variable Name - User::Name Direction - Input Data Type - LONG Parameter Name - 0 Parameter Size - -1
Variable Name - User::Name Direction - Input Data Type - LONG Parameter Name - 1 Parameter Size - -1
This quickly gets out of hand and cumbersome if have 5-10 values for a name and forces me to add multiple assignments for the same name.
Is there an easy(-ier) way to do this?
Upvotes: 0
Views: 5744
Reputation: 56
The easiest (and most extensible) way, is to use a Data Flow Task instead of using an Execute SQL Task.
The good thing about this method is that you can make as extensible as you wish... validate each value with different criteria, modify the data, add business rules, discard non-compliant values (by checking the full number of complying values)... !
Have a nice day!
Francisco.
PS: I had prepared a couple more screenshots... but stackoverflow has decided that I am too new to the site to post things with images or more than two links (!) Oh well..
Upvotes: 2