If I have a String Variable in SSIS that contains a list of values separated by commas (or any other standard character) - would it be possible to load those values into an object variable, so that I could then use the Object variable as a resultSet enumerator and loop through each value?
[EDIT] Just to clarify the situation - I have approx. 15 variables that each contain a 1 or 0 - each variable determines whether a particular SSAS table needs to be processed during the job (1 = Yes, it needs to be processed 0 = no, don't process it).
What I want to do now is store the table names that WERE processed in an object variable, then loop through that list, writing a log entry for each to say it was processed during this job.
[EDIT #2] I'm not explaining this very well, but let me try to summarise - here is the current situation:
I have a variable, called strPartitionArray - this variable will now contain strings, separated by comma's, determined by this expression (appreciate that this has flaws - specifically if DimAbsenceUpdate is 0, it all falls apart, but hoping to figure out a fix for that separately):
(
@[User::DimAbsenceUpdate] == 1 ?
"Absence":""
)
+ (
@[User::DimGradeUpdate] == 1 ?
",Grade":""
)
+ (
@[User::DimContractUpdate] == 1 ?
",Contract":""
)
+ (
@[User::DimEmployeeUpdate] == 1 ?
" ,Employee":""
)
So, as an example, right now, that variable's value is: Absence,Grade,Contract
I need this stored in an Object Variable, so that I can loop through those 3 entries (Absence,Grade,Contract) as part of a SQL Task, so, using the code below, I am attempting to split out those 3 words into an Object called RecordProcessDateTime
public void Main()
{
String tmp = Dts.Variables["User::strPartitionArray"].ToString();
String[] tmpArray = tmp.Split(',');
Dts.Variables["User::RecordProcessDateTime"].Value = tmpArray;
Dts.TaskResult = (int)ScriptResults.Success;
}
Assuming the code above works, I then want to use RecordProcessDateTime as the enumerator for a Foreach Loop - running through each of those 3 words. The SQL Task within the container will write a log entry. Part of that SQL Task writes the word in question (Absence, Grade and then Contract) to a log Entry - that basically let's me know that the absence SSAS table was processed.
So, I've put the Script, the Foreach Loop (containing the SQL task) all into a sequence container. When I run the sequence container, it works(!) but only writes one entry to the log (when it should be writing 3) and that entry does not include any of the 3 words, it instead includes this: 'Microsoft.SqlServer.Dts.Runtime.Variable'
My assumption, is that the script is not actually putting those 3 values into the Object variable as expected, which is why the foreach loop only runs once and doesn't include any of the words.