﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Paul Clancy  / Real World Foreach Loop Container example / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 15:32:33 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>I would like to note that as of 4.8.2011, the images in the article are not viewable and give broken link errors. Thanks.</description><pubDate>Fri, 08 Apr 2011 16:56:05 GMT</pubDate><dc:creator>phouse</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Hiveru use full information. I have another type of question. I have used Foreach loop to import multiple files. But if one file has some problem whole package is erroring out, Instead of going for another file it stops.How do I solve this problem ? Saritha</description><pubDate>Wed, 31 Mar 2010 13:56:23 GMT</pubDate><dc:creator>saritha.ijjurouthu</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>[quote][b]mona.togatorop (5/21/2008)[/b][hr]I'm new to SSIS so this might be a very basis error but I'd appreciate somehelp...I've got error in Delete Old log File (File system Task) :[quote]Variable VarDeleteFileSName is used as a source or destination and is empty[/quote]Please help me.. Thank you[/quote]I know this is six months late, but I resovled this exact scenario by placing a default value for varDeleteFileSName when declaring the global variable in the package. After that, the File System Task ran as expected. I supposed it needed to know there was a value before it executes. And because the script had not yet assigned a value to the variable, the File System Task would not start.  Mark Maddox.</description><pubDate>Fri, 13 Nov 2009 13:40:44 GMT</pubDate><dc:creator>mmaddox 39987</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>x</description><pubDate>Fri, 13 Nov 2009 13:37:13 GMT</pubDate><dc:creator>mmaddox 39987</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>great articlesome time ago i played with something similar to import csv files with performance data but never got it to work in importing only the files that haven't been imported before. going to look at this again using a slightly modified version of your procedure</description><pubDate>Fri, 13 Nov 2009 12:22:02 GMT</pubDate><dc:creator>alen teplitsky</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Great article, thanks! Will help me to get startedBut at the end you wrote: "And that's it! Running the package deletes all backup files that haven't been restored except the newest sixteen".You do mean "that HAVE been restored", right? :)</description><pubDate>Fri, 13 Nov 2009 03:20:43 GMT</pubDate><dc:creator>thierry.vandurme</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Hi Paul,I read your article and it helped me a lot. One question I have is how can I add the file creation date to my table?Thanks a lot Sam</description><pubDate>Wed, 29 Jul 2009 18:05:42 GMT</pubDate><dc:creator>sam arteaga</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Just wonder how to set a folder (directory) using a global variable? When i use my variable Directory user:: &lt;myvariable&gt;, the SSIS finishes with message - "no files in the specified directory" (or something like that, no failure though). Yet , files are there and when i "hard-code" the path and execute the SSIS again, everything works. What am i missing?</description><pubDate>Sun, 26 Jul 2009 23:34:08 GMT</pubDate><dc:creator>oleg yuriev-460662</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>My pleasure, thank you very much for your kind comments.</description><pubDate>Sat, 14 Feb 2009 14:11:32 GMT</pubDate><dc:creator>Paul Clancy</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Paul - Just wanted to thank you for putting this "Real World" article up. I'm working on adapting an existing full-blown ETL/OLAP iterative process to use SSIS looping tasks to provide high-level control of detail low-level SP processing. The details of your Var defs, DeleteList DataFlow, and Convert Object variable script were just what I was looking for - thanks for taking the time to do this.-- BobS --</description><pubDate>Sat, 14 Feb 2009 09:30:45 GMT</pubDate><dc:creator>to.bobs</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>You'll need to do a bit of debugging. The first place I'd look is in the SQL statement that populates the [b]varDeleteFileList [/b]variable; if you run this as a query in the Management Studio do you get a result set? If not, that's your problem.If you do, try adding breakpoints in the script code just before the Dts.TaskResult line (for instance). That way you'll be able to see which (if any) values are being passed along.</description><pubDate>Wed, 21 May 2008 07:55:17 GMT</pubDate><dc:creator>Paul Clancy</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>I'm new to SSIS so this might be a very basis error but I'd appreciate somehelp...I've got error in Delete Old log File (File system Task) :[quote]Variable VarDeleteFileSName is used as a source or destination and is empty[/quote]Please help me.. Thank you</description><pubDate>Wed, 21 May 2008 03:04:13 GMT</pubDate><dc:creator>mona.togatorop</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Oh, good, the (?) parameter works. You still have to do the Parameter Mapping in the Execute SQL task (the parameter name = 0).Laura</description><pubDate>Thu, 20 Mar 2008 11:42:32 GMT</pubDate><dc:creator>laura garcia</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Sorry I couldn't get back to you earlier on this and save you the long search, but the cause of your problem was the OLEDB connection. My example uses an ADO.NET connection for the Execute SQL Task (this wasn't explicitly mentioned in the article - my apologies), in which case you need to use the (@FileName) syntax as described on the article.</description><pubDate>Fri, 29 Feb 2008 03:38:37 GMT</pubDate><dc:creator>Paul Clancy</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>thanks...I finally figure this out after long search. OleDB...connection.INSERT INTO tempTlogFileList                      (FileName)VALUES     (?)instead of INSERT INTO tempTlogFileList                      (FileName)VALUES     (@FileName)</description><pubDate>Thu, 28 Feb 2008 15:03:41 GMT</pubDate><dc:creator>tran008</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>As an after thought - depending on what you wish to do of course, you may have to execute the sql statement as a variable.  Out of curiosity I just put together a for each loop to save a series of .txt files into a table and this worked well by using a variable for the sql statement.  Let me know if you want any further detail on this method.</description><pubDate>Wed, 27 Feb 2008 17:09:14 GMT</pubDate><dc:creator>TeeGee</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>tran008,I think you need to provide a bit more basic information about what you are trying to do.  Where are you getting the @FileName parameter from anyway?  My thoughts are that it should be declared as a User::[varname] in the for each loop and then this mapped across to the parameter in the SQL Task, but without knowing what it is you are trying to do it is hard to be of more assistance.</description><pubDate>Wed, 27 Feb 2008 16:24:42 GMT</pubDate><dc:creator>TeeGee</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Paul,I get the same error...Here are a bit more detail on execute sql task:General tab:   resultset: None   connectionType: OLE DB   connection: UserServerConnection   sqlsourceType: Direct input   sqlstatement: insert into tmpTLogFileList(FileName) values (@FileName)   bypassPrepare: TrueThe Parameter Mapping is same above as you mention, exceptfor Data Type - Nvarchar, I can't fine the dropdown for String.I appreciate all you help thanks....Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "insert into tmpTLogFileList(FileName) values (@FileName)" failed with the following error: "Must declare the scalar variable "@FileName".". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.Task failed: Execute SQL Task</description><pubDate>Wed, 27 Feb 2008 10:22:51 GMT</pubDate><dc:creator>tran008</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Right-click your "Execute SQL Task". In the "Execute SQL Task Editor", go to Parameter Mapping. Add a parameter as follows:Variable Name -  User::varTLogFileNameDirection - InputData Type - StringParameter Name - @FileNameParameter Size:   -1   Hope this is now clear. Best of luck!</description><pubDate>Wed, 27 Feb 2008 09:39:36 GMT</pubDate><dc:creator>Paul Clancy</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Just came across your article and fine it very useful tools for me to learn sqlis. I have a problem with Execute SQL Task in the loop container: Insert into tmpTlogFileList(FileName)values(@FileName): Execute SQL Task: Executing the query "insert into tmpTlogFileList (FileName) values (@FileName)" failed with the following error: "Must declare the scalar variable "@FileName".".Must I declare @Filename as nvarchar(128) from the sql statement?thanks</description><pubDate>Wed, 27 Feb 2008 09:14:14 GMT</pubDate><dc:creator>tran008</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Sorry ;)</description><pubDate>Tue, 26 Feb 2008 00:39:45 GMT</pubDate><dc:creator>pclancy</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>I second that.  The for each loops are a great tool.  I use one with variables and script for looping through database backups on my main server to grab the latest dated ones and FTP them over to a secondary backup server (no I'm not really paranoid about losing data!)</description><pubDate>Mon, 25 Feb 2008 15:26:52 GMT</pubDate><dc:creator>TeeGee</dc:creator></item><item><title>RE: Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Great article.  I was just about to send a very similar article for submission.  Guess you beat me to it:)</description><pubDate>Mon, 25 Feb 2008 09:48:11 GMT</pubDate><dc:creator>J.D. Gonzalez</dc:creator></item><item><title>Real World Foreach Loop Container example</title><link>http://www.sqlservercentral.com/Forums/Topic459462-1206-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/SSIS/61987/"&gt;Real World Foreach Loop Container example&lt;/A&gt;[/B]</description><pubDate>Sat, 23 Feb 2008 13:44:34 GMT</pubDate><dc:creator>Paul Clancy</dc:creator></item></channel></rss>