Foreach Loop only looping once

Hi,
Please be patient and bear with me, for I am new to SSIS packages.
I am using SQL Server 2008 R2 to host the SQL Agent job and the SSIS package.
I am using Visual Studio 2008 Professional Edition for designing the SSIS package. It is version 9.0.30729, Version 3.5 SP1.
I am on a Windows 8 machine.
My Foreach Loop Container seems to iterate only once when it should iterate numerous times, and this issue happens BOTH when I execute the SSIS package from within Visual Studio AND when I run a SQL Agent job to execute the SSIS package.
For the solution within Visual Studio, I have False for the property Run64BitRuntime.
In the SSIS pckg in Visual Studio, I have in the Variables pane a number of variables and these following variables pertain to my problem:
Name: objRs      Scope: the name of the SSIS package     DataType: Object    Value: System.Object
Name: txtVendorFamilyNumber   Scope: the name of the SSIS package  DataType: String   Value: 111111
The value "111111" that I entered into the txtVendorFamilyNumber variable in the Variable Pane is NOT a realistic value as there are no vendor family numbers that have the value 111111. I will populate dynamically the real vendor family numbers
from within the SSIS package.
When I imported the SSIS package to SQL Server 2008 R2, via the ellipsis button for the Protection Level I chose the "Rely on server storage and roles for access control" choice.
Concerning the flow of the SSIS package, going down within Visual Studio from the beginning of the flow of the SSIS package, eventually I have an Execute SQL Task. In its General tab, it has "1252" for CodePage property, "Full result set"
for ResultSet property, "OLE DB" for ConnectionType property, "Direct input" for SQL Source Type property, "False" for BypassPrepare property, and the following for the SQLStatement property:
     select txtVendorFamilyNumber from tmpVendorFamily  where VendorID = (select min(VendorID) from tmpVendorFamily)
In the tmpVendorFamily table on SQL Server 2008 R2, there are 379 rows of results for the SELECT statement above (starting with the values 100110, 100115, 100120, 100130, through the LAST row's value 106370.
In the Parameter Mapping tab of the Execute SQL Task Editor, I have nothing. In the Expressions tab of the Execute SQL Task Editor, I have nothing.
In the Result Set tab of the Execute SQL Task Editor, I have the value 0 for Result Name property and I have the value User::objRs as the value in the Variable Name property.
This Execute SQL Task has a green arrow (Constraint evaluation operation, Success in Value drop down) to the Foreach Loop Container.
In the Foreach Loop Editor, in the Collection tab, I have "Foreach ADO Enumerator" as the value in the Enumerator property. In the drop down for ADO Object Source Variable, I have chosen the User::objRs, and I have the radio button "Rows in
the first table" selected.
In the Foreach Loop Editor, in the Expressions tab, I have nothing.
In the Foreach Loop Editor, in the Variable Mappings tab, I have "User::txtVendorFamilyNumber" for the Variable property and I have the value "0" for the Index property.
So in the Foreach Loop, I first have a Script Task with the ReadOnly variable User::txtVendorFamilyNumber and with the ReadWrite variable User::TESTING_OnlyTesting that I created with a package scope, string datatype, and no default value. This Script Task
has the following code for testing purposes:
Dim strFullVerbiage As String
strFullVerbiage = "The value is: "
Dts.Variables("User::TESTING_OnlyTesting").Value = strFullVerbiage + Dts.Variables("User::txtVendorFamilyNumber").Value.ToString()
Dts.TaskResult = ScriptResults.Success
I have next in the Foreach Loop Container a Send Mail task. In the Expressions tab of the Send Mail Task Editor, I have for the Message Source property the following:
      @[User::TESTING_OnlyTesting]
The remaining tasks (including FTP Tasks) in the Foreach Loop Container are disabled for now as I am trying to figure out why the Foreach Loop only iterates the FIRST time, only iterates once.
When I run on SQL Server 2008 R2 the SELECT statement from the Execute SQL Task, I get 379 rows of results. The default value 111111 that I entered into the Variable Pane for the txtVendorFamilyNumber variable does NOT exist in any of these 379 rows of results.
The 1st row of results has for the txtVendorFamilyNumber column the value 100110. Then the subsequent rows of results have the values 100115, 100120, 100130, et cetera, ending with the value 106370 in the last row of results.
I imported the SSIS package into Integration Services on SQL Server 2008 R2. When I imported to Integration Services, in the Import Package editor for the Protection Level I chose the "Rely on server storage and roles for access control" choice
because there are FTP Tasks and we needed to use this "Rely on server storage and roles for access control" choice.
I created a SQL Agent job that executes this SSIS package.
When I run the SQL Agent job, no error happens and I get only ONE email with the value 100110 for the vendor family number in it. I should get 379 emails total, the 2nd email showing 100115, the 3rd email showing 100120, et cetera.
When I was testing while executing the SSIS package from within Visual Studio, I did NOT have the Send Mail task and I only had enabled one Script Task that had the ReadOnly variable User::txtVendorFamilyNumber and the following lines of code:
MsgBox(CType(Dts.Variables("User::txtVendorFamilyNumber").Value, String))
Dts.TaskResult = ScriptResults.Success
Executing the SSIS package with only this Script Task enabled within the Foreach Loop Container, I would get the ONE message box showing 100110 but I would not get any message box for a SECOND ITERATION of the loop.
Since my txtVendorFamilyNumber in the Variables Pane has the default hard-coded value 111111 that does NOT exist in the result set of the Execute SQL Task that feeds the Foreach Loop, and since the first and only email sent shows the value 100110 when I
run the SQL Agent job that runs the SSIS package that is set up to send an email from within the Foreach Loop Container, the FIRST LOOP seems to run correctly and shows correctly the 1st value 100110 in the 379 rows of results that populate the Foreach Loop
Container. Why does the Foreach Loop Container NOT loop more than once?
Could anybody give me any suggestions as to what the problem might be?
I thank you in advance for your consideration of my problem. I have been reading and reading on the Internet to try to find a solution but I have not solved yet my problem with the Foreach loop only iterating once.
Thanks much to you.

Gregarious greetings Arthur,
I very much appreciate your reply.
This morning I figured out my problem with the help of a fellow employee.
In my original post higher up, I had typed about the SELECT statement in the Execute SQL Task that is just before the Foreach Loop Container and that populates the User::objRs, and this SELECT statement was in the old DTS package in an old ActiveX script
task. The SELECT statement was in an old DTS package in an old ActiveX script task and I am creating a new SSIS package to replace the old DTS package so that we can move from the old version of SQL Server to a new SQL Server 2008 R2 server. Here is that
SELECT statement:
 select txtVendorFamilyNumber from tmpVendorFamily  where VendorID = (select min(VendorID) from tmpVendorFamily)
That SELECT statement above returns ONLY ONE result. I had not noticed it. That SELECT statement fills the objRs result set. The green arrow goes from the Execute SQL Task that has the SELECT statement down to the Foreach Loop Container that loops over the
result set. Since the SELECT statement that fills the result set only has one row of results, the Foreach Loop only looped once.
So for the Execute SQL Task that populates the result set User::objRs, I changed the SELECT statement to be the following:
--In the Utilities DB, this tmpVendorFamily table
--has only two columns named VendorID and txtVendorFamilyNumber.  
SELECT DISTINCT txtVendorFamilyNumber
FROM Utilities.dbo.tmpVendorFamily
ORDER BY txtVendorFamilyNumber
Now the Foreach Loop will loop 379 times since the SELECT statement immediately above yields 379 rows of results.
So the Foreach Loop Container was fine. Its Collection tab has the "Foreach ADO Enumerator" for the Enumerator and has the "User::objRs" for the ADO Object Source Variable. Its Variable Mappings tab has "User::txtVendorFamilyNumber"
for the Variable and has "0" for the Index.
My problem was the SELECT statement in the Execute SQL Task that immediately precedes the Foreach Loop Container and that fills the User::objRs result set. The SELECT statement yielded only ONE row of results. When I corrected this morning that SELECT statement
so that it correctly yields 379 rows of results, the Foreach Loop Container loops 379 rows.
Thanks again for replying and trying to help. I very much appreciate it.
I consider this thread that I created to be closed since I figured out this morning how I needed to correct the SELECT statement in the Execute SQL Task that fills the result set on which the Foreach Loop loops.
Misko_Hviezdoslav   27-JAN-2015

Similar Messages

  • Producer consumer loop only execute once?

    Hello here,
    In my VI, the producer loop seems working continuously, but the consumer loop only execute once.
    I haven't used producer/consumer pattern before, could someone give me some ideas why this happens?
    My code is in attachment.
    Thank you in advance.
    Yaqiong
    Solved!
    Go to Solution.
    Attachments:
    parallel - Copy.vi ‏72 KB

    That would be the poor choice of using an event structure in the consumer loop.  As set up you must generate a mouse Leave or mouse enter event on Waveform Graph for the consumer loop to finish its first iteration. 
    Delete the event structure.  you don't need it to update a graph.
    Jeff

  • Strange issue with rights of account, used by SSIS (Foreach Loop Container does not return file names without Admin rights on server)

    Hello everyone.
    Faced very strange issue with account, which is used to run SSIS package.
    The specific package uses Foreach Loop Container to retrieve file names within the specified folder, and put them into Import file task.
    The package is set up to run under specific service account. This service account is given all permissions (Full control) to the folder where source files reside.
    So the issue is: SSIS package fails to execute this task (Foreach Loop Container and then Import), and shows that no files are found in the directory (although files ARE there).
    Once we're adding the service account into local Administrators group on the SQL Server, it works! Removing - does not work again. We cannot leave the service account as SQL server's admin as it's prohibited by our IT policies, and is just a bad practice.
    Any ideas, please? 
    MCP

    Here's the real log output:
    Date 16.04.2014 12:47:09
    Log Job History (RU-BW: Update)
    Step ID 1
    Server Server
    Job Name RU-BW: Update
    Step Name bw_import_cust_master_data
    Duration 00:00:02
    Sql Severity 0
    Sql Message ID 0
    Operator Emailed
    Operator Net sent
    Operator Paged
    Retries Attempted 0
    Message
    Executed as user: service_account Microsoft (R) SQL Server Execute Package Utility  Version 10.50.4286.0 for 64-bit  Copyright (C) Microsoft Corporation 2010. All rights reserved.    Started:  12:47:09  Error: 2014-04-16 12:47:11.45
        Code: 0xC0202070     Source: bw_import_cust_master_data Connection manager "Input"     Description: The file name property is not valid. The file name is a device or contains invalid characters.  End Error  Error:
    2014-04-16 12:47:11.47     Code: 0xC0202070     Source: bw_import_cust_master_data Connection manager "Input"     Description: The file name property is not valid. The file name is a device or contains invalid characters.  End
    Error  Error: 2014-04-16 12:47:11.48     Code: 0xC0202070     Source: bw_import_cust_master_data Connection manager "Input"     Description: The file name property is not valid. The file name is a device or contains invalid
    characters.  End Error  Error: 2014-04-16 12:47:11.48     Code: 0xC020207E     Source: Import file Flat File Source [1]     Description: The file name is not valid. The file name is a device or contains invalid characters.
     End Error  Error: 2014-04-16 12:47:11.48     Code: 0xC004701A     Source: Import file SSIS.Pipeline     Description: component "Flat File Source" (1) failed the pre-execute phase and returned error code 0xC020207E.
     End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  12:47:09  Finished: 12:47:11  Elapsed:  2.324 seconds.  The package execution failed.  The step failed.
    MCP

  • How to bypass errors in the control flow in a foreach loop in SSIS?

    Hi All,
    Can anyone please get me through the solution for the below scenario:
     - I have multiple XML files existing in the source system from where I need to read the data from each XML, validate and pull to staging database. 
    - So, to read the XML files from source, I have a foreach loop which will get the XML files from the source folder one by one and executes.
    - There are multiple data flow tasks, script tasks, SQL tasks etc in the foreach loop to validate the business requirements.
    Question: If there is an error in any of the component in foreach loop, it should log the error, come out of the loop from that point and pick up the next file with out stopping the execution. How can I achieve this?
    Thanks,
    Sri

    Hi Sri,
    According to your description, when there is an error in any of the component in Foreach Loop Container, you want to continue processing rest of the loop after recording the error file details.
    To achieve your requirement, the first thing you need to do is create an OnError event handler for the Data Flow (or any other child executable). Once the event handler is created show the system variables in the variables window, locate the Propagate variable
    and set it to false.
    For more details, please refer to the following two blogs:
    http://www.codeproject.com/Articles/384690/In-SSIS-how-to-continue-a-for-each-loop-container
    http://visakhm.blogspot.in/2013/03/error-handling-in-ssis-loops.html
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Using an ssis variable object as a data source in a foreach loop container

    hi we run 2012 std.  I have an ssis var of type object that is hydrated from a dynamic query in an execute sql task.  I can count on one thing in this object and that is that ID will always be the first "col" on each "row". 
    Otherwise, resultset can contain a variety of things based on params passed to this sub pkg.
    I'd like to introduce a for each loop on this object and tap into index 0, ie the id column.  
    The first question is "will I be able to parse this object's id in a for each component?".
    In the for each loop container properties, I c an item enumerator, ado enumerator, ado.net schema rowset and variable enumerator as enumerator choices.  Which do I want if the answer to the 1st question is yes?

    hoping 2 avoid a data flow.  I wonder if what u r saying is that I cannot use an felc to do this.  Or if u r showing one of many alternatives.
    Sorry, bad title.  I just changed that.
    I just tried foreach from variable enumerator and aborted with a message that said my variable "coll" doesn't have an enumerator.  Going 2 try some of the other choices.
    I just tried ado enumerator and from what I can c it isn't actually iterating thru my resultset even once. 
    I just tried a foreach item enumerator giving "column 0" a data type that matches my ID but from what I can tell the component isn't iterating thru my collection. 
    ado.net schema rowset doesn't look inviting at all in that it looks like it wants to go back to the db.  Not what I had in mind having already gotten this resultset into memory.
    according to this article u r supposed to be able to do this using ado enumerator
    social.technet.microsoft.com slash wiki slash articles slash sis-looping-over-object-variables-with-as-ado-enumeration-in-foreach-loop-container.aspx

  • Yet another Try Catch question. Iterating through a ForEach loop

    Confused on error handling in a Powershell ForEach loop. I’m looping through a list of registry keys, attempting
     to open each one. If it succeeds, I do a bunch of stuff. If it fails, I want to skip to the next iteration.
    If I was doing It in VBScript I’d do this:
    For Each Thing In colThings
    Open Thing
    If Err.Number <> 0 Then
    “oops”
    Else
    Do stuff
    Do stuff
    Do stuff
    End If
    Next
    This is what I came up with in PowerShell. It seems to work, but just doesn’t seem powershell-ish. There must be a better way to use the catch output than just creating a $return variable and assigning it success or fail?
    ForEach ($subKeyName in $subKeyNames)
    try{$subKey = $baseKey.OpenSubKey("$subKeyName")}
    catch{$return = "error" }
    If($return -eq "error" )
    “Oops”
    Else
    Do stuff
    Do stuff
    Do Stuff

     
    I totally get what you're saying about formatting. I don't' have any habits yet, since I've only been working in Powershell since... well, what time is it now?
    Unfortunately, It Has Been Decreed that we are no longer to use VBScript for any engineering solutions at work, so my 15 years experience in it now needs to be transitioned over asap. I don't have the luxury of crawling before I run. I'm trying not to be
    frustrated, but it's like an English major waking up one day and being told "You must now speak French exclusively. Here's a book."
    The Do Stuff example of my ForEach loop is about 50 lines of code involving matching values in subkeys of this registry key with another and collecting output. I tried wrapping the whole thing in a try section based on some examples, but it seemed odd, that's
    why I'm asking. I'm used to tightly focused error handling at the point where an error may occur.
    In this example I'm only interested in whether or not I can open the subkey (it exists, but I may not have permission). If I can't, there's no point in continuing with this iteration of the loop, I want to skip to the next one. So why include all the "Do
    Stuff" in the the try section? From a readability viewpoint, it doesn't seem helpful.
    Also, there may be more error handling deeper in the code. If I then put that in a try/catch, and then something else inside that, now I have nested try/catches mixed in with nested if/elses, all wrapped in a For loop.
    Again, I can see how it works logically, but for readability not so much, and having all these braces 50 lines apart to match up is giving me eye strain :).
    It sounds like David is agreeing with jrv, that putting the entire ForEach loop code into a try/catch is the conventional way to do it. I guess it makes as much sense as putting it all in an If-else-Endif, and I just need to adjust my paradigm.
    But if not, my specific question was more along the lines of, is there a built in way to tell that the catch section has been executed, rather than me using it to populate an arbitrary variable and then read it? In VBScript, you execute something, and the
    next line, you check the Err.number. I wasn't sure if you could do that with a try/catch.

  • Nested af:forEach loop

    Hi,
    How can i use nested af:forEach loop. I can't use af:iterator for sure, please provide solution only using af:forEach.
    <af:forEach items ="#{bindings.parentVO.rangeSet}" var ="parent">
    <af:forEach items ="#{parent.chidVO}" var="child">
    <af:outputLabel value="#{child.empId}"/>
    </af:forEach>
    </af:forEach>
    here child.empId is not printing any value. Data is proper and bindings are also fine. Please guide why forEach is not working with parent-child VO?
    I guess in second forEach loop I am missing something like parent.childVO._something_ i tried using parent.childVO.rangeSet and other option but it didn't work
    Edited by: 899404 on Mar 14, 2012 10:47 AM

    you could use af:iterator for your use-case.
    Please find sample based on your use-case:
    NestedIteratorSample.jspx:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document title="Sample" id="d1">
    <af:messages id="m1"/>
    <af:form id="f1">
    <af:panelGroupLayout id="pgl1" layout="vertical">
    <af:iterator rows="#{bindings.Departments.rangeSize}" var="row"
    value="#{bindings.Departments.treeModel}" id="outerIt">
    <af:outputText value="Employees in #{row.DepartmentName}" id="ot1"/>
    <af:iterator rows="#{bindings.EmployeesVO.rangeSize}" var="detailRow" value="#{row.EmployeesVO}"
    id="innerIt">
    <af:outputText value="#{'----------------'} #{detailRow.FirstName} #{detailRow.LastName}" id="ot2"/>
    </af:iterator>
    </af:iterator>
    </af:panelGroupLayout>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>
    NestedIteratorSamplePageDef.xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.60.17" id="NestedIteratorSamplePageDef"
    Package="com.samples.subbanasolutions.view.pageDefs">
    <parameters/>
    <executables>
    <iterator Binds="Departments" RangeSize="25" DataControl="AppModuleDataControl" id="DepartmentsIterator"/>
    </executables>
    <bindings>
    <tree IterBinding="DepartmentsIterator" id="Departments">
    <nodeDefinition DefName="com.samples.subbanasolutions.model.DepartmentsVO" Name="Departments0">
    <AttrNames>
    <Item Value="DepartmentId"/>
    <Item Value="DepartmentName"/>
    </AttrNames>
    <Accessors>
    <Item Value="EmployeesVO"/>
    </Accessors>
    </nodeDefinition>
    <nodeDefinition DefName="com.samples.subbanasolutions.model.EmployeesVO" Name="Departments1">
    <AttrNames>
    <Item Value="EmployeeId"/>
    <Item Value="FirstName"/>
    <Item Value="LastName"/>
    </AttrNames>
    </nodeDefinition>
    </tree>
    </bindings>
    </pageDefinition>

  • SSIS Package to load multiple excel sheets using foreach loop container

    I am creating a SSIS package which is accessing an excel file and then using a Foreach loop container to load each tab to sql server. However when I try to configure the Excel source, I get the following message
    "The argument system_comobject cannot be converted into parameter type. Additional Information - Object must implement iconvertible (mscorlib)"
    Any help to resolve would be much appreciated.
    thanks
    Scott

    If the title is only using column D and the rest of the columns are empty on sheet1/row1
    AND
    if only sheet1 as headers,
    THEN you can try something like the following
    do NOT select row 1 as header or anything.
    In your foreachloop > dataflow, you will start with EXCEL connection then Conditional Split inside which you will define one case for which expression should be like If column D has value like "Title expression" && Column A == "Column A Header
    name" THEN yay or nay. You might want to look into
    FINDSTRING function to assist with this (if you choose to use FINDSTRING, you are looking for !isNull for this case..If it finds the string you are looking for, it will pass an int value (title + header) if it doesn't find the string, it will pass
    NULL (data)) or you can say If Column A, B, C,E,F,G...is NULL and D is NOT NULL && Column A = Column A Header string, then Case 1 else default.
    The default output would be the real data.
    So when sheet 1 is processing, you will have Case 1 output with 2 rows (title + header) and Default output with the rest of the rows (real data).
    For other sheets, you will have Case 1 output with 0 rows (no title + header) and Default output with the data rows.
    The above sln assumes that the data in each sheet is similar in datatypes and length perspective, you have defined input/output datatypes properly, and etc.

  • Setup ForEach Loop with 2D Array

    Hello All,
      Would like to know how (if possible) to configure the "ForEach Loop" step in TestStand for an empty 2D Array.  What I have is a 2D array of character strings that represent sets of configuration parameters (i.e. each row contains several columns of parameters, and there are an undetermined amount of rows).  With the ForEach Loop, I would want it to loop once for each parameter row (not for each column of each row).  Right now it looks like it runs once for every column.  Please advise.  Thanks much.
    Regards,
    GSinMN     

    Hi GSinMN    
    There’s a TestStand known issue of transposing an incoming array from LabVIEW, if you are importing and array from LabVIEW you can transpose that array prior to pass it to TestStand. Because seems that the behavior you are seeing is due to a transposed array.
    Here are some links with more information
    http://www.ni.com/white-paper/8681/en/#161523_by_Category
    http://forums.ni.com/t5/NI-TestStand/TestStand-Foreach-tutorial-or-example/td-p/1125230
    regards
    Chris S.

  • Foreach loop

    Hello,
    I am trying to convert a normal for loop to the new foreach loop. I was able to do one function that prints every element, but can't seem to be able to modify the elements in the array.
    //This works ok
    public static void printjoy(int [][] array1)
    System.out.println();
    for (int x[] : array1)
    for (int y : x)
    System.out.print(y);
    System.out.println();
    System.out.println();
    //This causes no errors, but it doesn't do the "element plus 10". It just returns the same array unchanged.
    public static void adjArray(int [][] array2)
    for (int x[] : array2)
    for (int y : x)
    y = y +10;
    This is the array declaration and initialization:
    int [][] joy = {
    {66,4,73,4},
    {81,82,81,18},
    {20,22,69,76},
    {71,65,84,79}
    This is how I call the two functions:
    printjoy(joy); //original array
    adjArray(joy); //add ten to each element
    printjoy(joy); //print adjusted array
    Thanks in advance for any help.
    Message was edited by:
    mgkicker

    I am trying to convert a normal for loop to the new
    foreach loop. I was able to do one function that
    prints every element, but can't seem to be able to
    modify the elements in the array.Right, you can't do that.
    for (int ii : arr) {
      ii = 0; // just changes ii, not the array element it's a copy of
    is equivalent to
    for (int ix = 0; ix < arr.length; ix++) {
      int ii = arr[ix];
      ii = 0; // just changes ii, not the array element it's a copy of
    }With the foreach loop, you don't have access to the array, only to the element's value.

  • ForEach Loop - Parsing XML subgroup into Variables

    Hi all,I am designing a new ETL process using SSAS.
    We have a controller package which receives an XML string at run time into a variable called BatchRequest :-
    <Batch>
    <Request>
    <Name>Filemon</Name>
    <Params>
    <filepaths>
    <Sourcepath>d:\temp</Sourcepath>
    <Destpath>D:\temp2</Destpath>
    <Archivename>\Archive</Archivename>
    </filepaths>
    </Params>
    </Request>
    </Batch>
    The Batch can contain a number of Requests and a ForEach Loop is used to parse the text for the Name node and the text for the Params Node into variables RequestName and RequestParams respectively.
    however, what I want to be able to do is to take the text for <name> into Requestname but take the entire XML sub string for <Params> into RequestParams.
    At the moment I get the text only (e.g. d:\tempd:\temp2\Archive).
    The Requestname is used by an XML task within the ForEach loop to retrieve full package path details from an external config file, and hence it only needs to be a keyword.
    I played with the idea of including <Params> as a subnode for <Name>, only populating RequestName in the loop parser and then having an XML task which would parse the related parameter string, but i don't know how to tell the XML task that I
    want the parameter string where the <Name> is Filemon (in this example).
    Can anyone give me some suggestions or pointers?
    Thanks
    Iain
    Iain

    Hi idcowden,
    Glad to hear that you have resolved the issue on your own. Thank you for sharing the solution.
    Regards,
    Mike Yin
    TechNet Community Support

  • Foreach loop help

    I am trying to create a foreach loop that takes all txt files in Program Files and print only the names of files over 10KB.
    This is what I got:
    foreach($file in (Get-ChildItem -Path "c:\Program Files" -recurse -Include *.txt |
    Select-Object FullName ))
    if($file.size -gt 10KB)
    Write-Host $file
    I've been testing around with this for a bit now and doing some Googling to no avail, it'll work if I don't try to sort it by size and ask it just to print the name of all text files in Program Files. Any nudge in the right direction would be appreciated.

    Let me be more explicit.  Whatou posted is not a loop.
    Always start with HELP when you are learning.  Ask your teacher to explain to you how to use HELP.
    help foreach.
    A ForEach loop cannot solve your issue here. You need to filter the results of a recursive search. In PowerShell this is almost never done with a loop. If your teacher tries to tell you otherwise you need to fire the teacher or take your money to a different
    school.
    Of course it may be more likly that you just didn't pay attention in class and are now asking us to do your homework for you.
    Sorry.  We don't do homework for children. This is a site for technicians who use scripting professionally. If you want to be a professional you need to do your homework No cheating. We are watching.
    ¯\_(ツ)_/¯

  • Is it possible to load multiple .xlsx files into a SQL Server Table using SSIS and a Foreach Loop Container when each Excel spreadsheet is comprised of two different worksheets

    So we have an Invoice .xlsx File from a 3rd party vendor. It contains two worksheets..."Enrolled" and "Engaged". The data and data columns in each worksheet is different. Is it possible to loop through multiple .xlsx files using SSIS
    and a Foreach Loop Container for each spreadsheet, and then another Foreach Loop Container to control each worksheet, and pump the Excel data into a SQL Server Table first for "Enrolled" and then for "Engaged"? How can I control the Foreach
    Loop Container in SSIS to process ONLY the "Enrolled" worksheet first? And then the "Engaged" worksheet next?
    I know I have multiples out here and I apologize for that...but right now it seems as though I take three steps forward and then two back.
    Any help would be GREATLY appreciated!
    Thanks in advance!

    If the structure of the Excel sheets does not change from file to file then you can by having one ForEach Loop processing always the "Enrolled" sheet and another always the "Engaged" this is doable because the Excel OLEDB connector allows
    to pick individual sheets, it is problematic therefore when sheet names themselves change.
    MSDN has an example: https://msdn.microsoft.com/en-ca/library/ms345182.aspx
    Arthur
    MyBlog
    Twitter

  • Foreach loop, containers and transaction settings and continuing a loop even if a task fails

    I have a foreach loop and a container inside that.  Inside the container are a bunch of tasks.  When one of these tasks fail, I want it to fail the parent container, but not the loop or the package.  
    The package will be run from a sql agent job.  Right now, the package works, but when a task fails inside the container, the sql agent job stops with failure.  I want it to continue unless one of the tasks OUTSIDE of the loop or container fail.
    Am I correct to say that since the foreach loop is the parent of the container, and as long as the foreach loop doesnt fail, the package should continue?

    Hi Shiftbit,
    Yes, the failure of the Script Task will fail the Sequence Container, the Foreach Loop Container as well as the package even though you have set the FailParentOnFailure and the FailPackageOnFailure properties to False. That’s because the package implicitly
    uses Event Handlers to control the failure propagation even though we didn’t add any Event Handlers explicitly. So, if you don’t want the failure of the Script Task to affect its containers and the entire package, you should add an empty OnError Event Handler
    for the Script Task, and then set the value of the System Variable Propagate of the Event Handlers to False.
    If you don’t want the other tasks in the Sequence Container fail the Loop container as well, you don’t need to repeat the operations on each task, instead, you only need to do the same on the Sequence Container.
    References:
    http://agilebi.com/jwelch/2008/06/29/continuing-a-loop-after-an-error/#comment-57484
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/08/09/ssis-logging-and-event-propagation.aspx
    Regards,
    Mike Yin
    TechNet Community Support

  • Populate a dataset in a foreach loop

    Hi,
    I am trying to populate a dataset in foreach loop, but I have difficulties getting it working.
    I have a set of plan_handles in a dataset. Now I want to go through them and execute a query to get the details about the plans. The result should get into a dataset (that I later will SqlBulkCopy into a database).
    I have this code. I can see that the queries are executed against the server, but when I look at $Plans.Tables[0] it only contains one row.
    foreach ($Plan in $PlanHandles.Tables[0])
    $PlanHandle = $Plan["plan_handle"]
    $SqlSourceConnection.Open()
    $SqlCmdPlanGet = New-Object System.Data.SqlClient.SqlCommand("SELECT GETDATE() AS [timestamp], @plan_handle AS plan_handle, [dbid], objectid, number, encrypted, query_plan FROM sys.dm_exec_query_plan(@plan_handle)",$SqlSourceConnection)
    [void]$SqlCmdPlanGet.Parameters.Add("@plan_handle",$PlanHandle)
    $SqlCmdPlanGet.CommandTimeout = 30
    $SqlAdapterPlanGet = New-Object System.Data.SqlClient.SqlDataAdapter($SqlCmdPlanGet)
    $Plans = New-Object System.Data.DataSet
    $SqlAdapterPlanGet.Fill($Plans)
    $SqlSourceConnection.Close()
    I have been reading about it and I understand, that it is something with that I should specify the datatable, but I am not sure how to get the code right.
    Ola Hallengren
    http://ola.hallengren.com

    Hi,
    What is the below code outpting:
    $PlanHandles.Tables[0]
    we may need to run each line and found out whether proper value was set to proper variable.
    I also suggest we post in the official scripting guys forum for further analysis, as I am not familar with SQL:
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
    Regards,
    Yan Li
    Regards, Yan Li

Maybe you are looking for

  • Internal Error 2502 - JRE (Java SE Runtime 5.02u22) ...please help!

    Hi Everyone, I am setting up an account to submit documents to the FDA through an electronic submission gateway. It's been one thing after the other. I finally made progress on the checklist. The next requirement is to download JRE and JCE. Anytime I

  • Error getting license: License Server Communication Problem: E_STREAM_ERROR: ???

    This is occuring on DRM ebooks. The vendor where I purchased has reset the licenses and I have authorized my computer. Please help...I need to download these books asap. Thanks!

  • ESS Leave Reqest WD not displaying messages

    Hello guys, The ess webdynpro for leave request is not displaying warning messages like collisions, or no absence quota exits etc. These messages do get displayed while creating an absence in PA30. I've debugged the FM PT_ARQ_REQUEST_CHECK which is n

  • 2 channel CTR0/CTR1 ouput synchronously

    I am using PXI-6259 under Measurement studio VC++ and trying to generate 2 counter output synchronously. ********** DAQmx *************** //set output channels  (DAQmxCreateCOPulseChanFreq(CTR0_Task,"Dev3/ctr0ev3/ctr1","",DAQmx_Val_Hz,DAQmx_Val_Low,0

  • Dimension Time - Level property SEMESTER value?

    Hello all, I'm triying to organize a time dimension this way: -YEAR   -SEMESTER     -QUARTER       -MONTH I've an issue, and it's when I'm setting the LEVEL property to the corresponding semester in the hierarchy. If I set it to SEMESTER, the dimensi