Capture Files With ForEach Loop And Execute Sql Task
Feb 27, 2008
Hi all,
I'm trying to capture the file name and insert to the Database with Loop Container and Execute Sql task...However when I run, I get error with the input parameter.
In my Sql Task, the parameter mapping:
Variable name: user::variable,
direction: input,
Data Type: Varchar,
parameter name: @xVariable,
parameter size: -1
connectiontype: OleDB
sourcetype: direct input
statement : insert into xtable(xcolumn) values(@xVariable)
Anyone have any other suggestion how to capture the filename and input in the database?
thanks
View 4 Replies
ADVERTISEMENT
Jun 21, 2007
OK. I give up and need help. Hopefully it's something minor ...
I have a dataflow which returns email addresses to a recordset.
I pass this recordset into a ForEachLoop configuring the enumerator as (Foreach ADO Enumerator). I also map the email address as a variable with index 0.
I then have a Execute SQL task which receives this email address as a varchar variable (parameter 0) which I then use in my SQL command to limit the rows returned. I have commented out the where clause and returned all rows regardless of email address to try to troubleshoot this problem. In either event, I then use a resultset to store the query result of type object and result name 0.
I then pass this resultset into a script variable to start parsing the sql rows returned as type object. ( I assume this is the correct way to do this from other prior posts ...).
The script appears to throw an exception at the following line. I assume it's because I'm either not passing in the values properly or the query doesn't return anything. However, I am certain the query works as it executes just fine at the command prompt.
Try
ds = CType(Dts.Variables("VP_EMAIL_RESULTS_RS").Value, DataSet)
My intent is to email the query results to each email address with the following type of data by passing the parsed data from the script to a send mail task. Email works fine and sends out messages but the content is empty. I pass the parsed data as string values to the messagesource and define the messagesourcetype as a variable in the mail task.
part number leadtime
x 5
y 9
....
Does anyone have any idea what I might be doing wrong?
thanks
John
View 5 Replies
View Related
Sep 10, 2007
Hello All
I was trying to insert some row from one table to another of different database.
I was using Execute SQL task along with Foreach loop container.
In my execute SQL task I am using this query
SET IDENTITY_INSERT dbo.Table1 ON
INSERT INTO dbo.Table1
SELECT * FROM DB2.dbo.Table2
WHERE TableKey = ?
When executed I get this error:
failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
While the same query when executed in Management Studio Its successful.
The properties I set
For Each Loop Editor Settings:
1) Collection: a) Enumerator Set to ForEach ADO Enumerator
b) ADO Object Source Variable: User:bjectVariablename
c) Checked Rows in the first table
2) Variable Mapping: New Int Variable2 and Index = 0 to set it to first colunm.
3) Expression: Left blank
Execute SQL Task Editor:
1) General: a) Timeout : 0
b) CodePage: 1252
c) Result Set: None
d) SQLSourceType: Directinput
e) SQL Statement: SET IDENTITY_INSERT dbo.Table1 ON INSERT INTO dbo.Table1 SELECT * FROM DB2.dbo.Table2 WHERE TableKey = ?
f) BypassPrepare: False
2)Parameter Mapping: Variable Name : New Integer variable2 selected
Direction: Input
DataType: Long
ParameterName: 0
Can somebody help me in this regards.
Reference:
a) http://www.whiteknighttechnology.com/cs/blogs/brian_knight/archive/2006/03/03/126.aspx
View 10 Replies
View Related
Jan 8, 2008
Hi,
I am trying to use SSIS.Execute Process Task within Foreach loop . The task should unzip a a variable gzip file provided to it from the previous task
to execute the command from cmd C:Program FilesGnuWin32ingzip.exe -d -k c:folderfilename
My input in the Execute Process Task as follow:
The command line: C:Program FilesGnuWin32ingzip.exe
Argument: -d -k c:folder
Variable: User::var_filename
keep getting error
The process exit code was "1" while the expected was "0".
Thanks
View 3 Replies
View Related
Mar 21, 2007
Hi:
I am a R data miner who is new to SQL and SSIS and would appreciate any help.
I wanted to automate the process of creating and processing decision tree models for every county in the Country. I wanted to use the foreach loop for iterate through all the counties. I wanted the foreach enumerator to be used by the XMLA code that creates the model so it would append it to the name of the model and i would get a different model for every county. I am not sure how to have the XMLA code accept foreach loop enumerator.
Any help would be greatly appreciated and if you could direct me to a previously done example that would greatly benefit me.
Thank you
avneet
View 1 Replies
View Related
Jul 19, 2007
hi
I am trying to execute a UDF in an Execute SQL Task within a Foreach loop.
I have an Execute SQL task to get the dataset (Firstname, Lastname, CompanyID) which is going into a full result set called @PendingPar. The Foreach Loop is set to a Foreach ADO Enumerator against @PendingPar and I have created 3 variables at the Foreach Loop scope level called @Firstname (String), @Lastname (String) and @CompanyID (Int32). These are mapped in the Foreach Loop as index 0,1 and 2.
Within the Foreach Loop I have an Execute SQL Task with the sql command
select dbo.udf_GetParTitle (?,?,?)
In the parameter mapping I have Variable Name = User::Firstname Direction = Input Data Type = VARCHAR and Parameter Name = 0, User::Lastname, Input, VARCHAR, 1 and User::CompanyID, Input, VARCHAR,2
Finally the UDF returns a @NewPar value so i have the result set in the execute sql task to Single Row which goes into variable @NewPar. This @newPar will be used later but I cannot get the first bit to work yet.
the error message i get back is
Error: 0xC002F210 at Execute SQL Task 1, Execute SQL Task: Executing the query "select dbo.udf_GetParTitle (?,?,?)
" failed with the following error: "Syntax error, permission violation, or other nonspecific error". 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 1
the initial execute sql task where the dataset is selected works fine but it is within the foreach loop that it fails.
any help gratefully recieved
View 6 Replies
View Related
Jan 18, 2007
Hi ALL,
Getting Access Denied To FileName Error When Using the Execute Sql Task (With File Connection) into a Foreach Loop Container.
Please Note :
I have a folder containing .sql files. I have to dynamically loop through the files and send them as a File connection Folder to the Execute Sql Task.
When I run this Package I am getting the follwoing error :
[Execute SQL Task] Error: An error occurred with the following error message: "Access to the path 'C:ProjectsFuzzy Lookup DataFlow ExampleScripts' is denied.".
Also I have logged in to the machine as Administrator and to Sql Server with sa.
Please help.
Thanks.
Regards,
Salil
View 1 Replies
View Related
Apr 4, 2007
How do you sort files from the Foreach loop container?
I love this component, except I can't get it to sort by filename.
Nice to know how to sort by timestamps also.
Dave
View 27 Replies
View Related
Feb 9, 2007
Hi - I'm new to SSIS and am having problems figuring out how to do the following.
I need to load data from flat files into SQLserver 2005 and have created the data flows ok, but my data files are *not* located in a single directory so I cannot use the foreach file enumerator option in the foreach loop container collection. Please correct me if I'm wrong?
My approach has been to execute a SQLcommand to get the filenames from another database table and to use the foreach ADO enumerator option and mapping the returned filenames to a project scoped variable (data type object since it is a rowset).
My problem comes when I edit the properties of the connection manager to try to use that variable for the connectionstring property in the expression editor. I get an error because the datatype of the variable is not supported in an expression.
Can anyone tell me how to correct this or outline another way to solve my problem?
thanks
View 6 Replies
View Related
Nov 8, 2006
Hi,
My Foreach Loop container has 10 different task inside. I want to execute the first task only one time. I have a variable with increases for each repition. How can I put precedence contstraint on the first task so that it should execute only first time and other task has to execute all the time.
Thanks
View 4 Replies
View Related
May 24, 2007
All,
I have a package that loops over ~60 Excel files in a directory. Each
file has three named ranges in it, which I import into different
tables. Sometimes the package runs without a hitch, sometimes it
chokes. But it is intermittent.
If I pull the control flow components out of the foreach loop and
point the Excel connection manager to the specific Excel file that has
caused the package to choke, I get a message in the dataflow component
pointing to the named range that "the metadata of the following output
columns does not match the metadata of the external columns......Do
you want to replace the metadata of the output columns with the
metadata of the external columns?" When I choose 'yes', then the
file will be loaded. then I can put the control flow components back
into the foreach loop and the file will run again, successfully, along
with some more, until it chokes again....
So, first of all, does anyone have any insight into this? Sometimes,
somedays, these files will load with no problems. These exact files;
I am having to reload constantly... Other times, like today, it is a
battle.
Otherwise, is there a way to get Integration Svcs to handle the
metadata issue on the fly???
Any ideas, resources, references, war stories, or good clean jokes
would be appreciated,
Kathryn
View 6 Replies
View Related
Jun 17, 2006
Hi,
My requirement is I have to read 2 sets of files from a folder. For example, I have to read all files starting with either 'a' or 'b' only. In 'Foreach Loop', if I say 'a*,b*', it is not working. Instead of comma (,), I tried colon, semi-colon and pipeline characters also. It is not working. So I am using 2 loops now. But I would like to know is there any way to do it using a single loop?
Thanks.
View 8 Replies
View Related
Jan 8, 2008
In all of our extract packages, we use a foreach loop container to grab files from the 400 sitting out in a certain directory. For this particular package, we have specified the files should be named RP*.* We know there are several files out in the directory. The package runs without error and completes, but says no files were found in the directory with that name. What could be causing this issue? Thanks!
View 3 Replies
View Related
Aug 23, 2007
Hi I am trying to load a bunch of excel files into a table and running into tables
I create a seq container--> add a foreach loop control task configure a variable thats ok as I am displaying the files names through script
I am stuck as how to configure the next data flow task to load into a destination
I create a source excel and then map the expression to the variable but the destination SQL connection is not able to see this one
Any ideas what I am doing wrong
Thanks
Po
View 3 Replies
View Related
May 9, 2008
Hi I have created a web service task that sits inside of a foreach loop. The loop is a ado enumerator. This loop is going to loop through about 35,000 records and make 35,000 web service calls.
So far through my testing, I have gotten it to read and write everything correctly, but each call to the web service takes about 1-2 seconds and maxes out the CPU. This would take almost all day for this web service to run at 100% CPU power all day. We want to be able to run this a few times a day or at least once a day.
I have disabled all of the other tasks in the foreach loop so it just calls the web service task and found that it's the web service task that takes up 100% of the CPU and takes 1-2 seconds to run. I have also tried creating a mock web service on the server that just sends back the same mock data, so it's extremely fast, but the Web Service Task still maxes out the CPU and takes 1-2 seconds per call.
I have tried this out on 2 different servers, all with a few gigs of ram they're not using. It seems more like it's a CPU thing, or that the Web Service Task has a high overhead that each time in the loop it takes 1-2 seconds to create the task.
Anyone have any advice?
Thanks,
-Will
View 6 Replies
View Related
Jul 27, 2006
well i am trying to follow the example of msdn help on how to loop through excel files and it doesn't work. the variables have the project scope. what can i do?
View 11 Replies
View Related
Feb 23, 2008
ummm. sorry, I've read and seen the tutorials but somehow and missing this.
I have a foreach container. Inside a dataflow task, with an XML source, a data conversion (cause of urrr UNICODE) and and an ole DB data source.
By design (and for this simple example), I get a volation if I attempt to load loads with out deleting entries from my table. No biggie, I would just like this simple package to rename my file to extension .good or .bad depending on success of each loop.
Where and what do I need for this?
Thank you for any help or information!
View 3 Replies
View Related
Dec 18, 2007
Hi Guys
The problem is...
When i try to bulk insert a single file its working fine. When i want to loop a set of files in a folder and use Foreach Loop and BulkInsert Task...its failing..
In the flat file connection When i specify usage type as existing file...its loading the same file "n" number of times where n is the number of files in the folder.
When i select usage type as existing folder i get error " Cannot bulk load because the file "....folder" could not be opened. Can someone help me out with this?
I have sql 2005 as as separate instance...beside my 2000 which is default
Thanks!
View 9 Replies
View Related
Aug 9, 2007
Hi,
I am using an XML task for validating the XML data against the Schema XSD. I have more XML Files with same the schema. I have to used a for loop container which has an XML task for validate XML. The loop container gets the XML File into variables name "XMLFileName" which the loop current file, in turn, used by XML Task for validation.
XML task is configured in the option "Validate". I have provided the XML Data in variable name "XMLFileName" also get the name from the loop container and XSD file content File Connection. XML Task stored the result in the another variable name "OKFormat". FailOnValidationFail property set to false.
It had the error when I run the package, the error msg as below:
Error: 0xC002F304 at XML Task, XML Task: An error occurred with the following error message: "Data at the root level is invalid. Line 1, position 1.".
Error: 0xC002928F at XML Task, XML Task: Property "New Source" has no source Xml text; Xml Text is either invalid, null or empty string.
Task failed: XML Task
After that, I had to change the source type from Variable to File Connection, and had to test fixed to some xml file it had ok for validate the XML file againt XSD.
I don't know this is the wrong setting or bug of SSIS, anyone can guide me through.
View 7 Replies
View Related
Nov 3, 2006
Hi everyone,
do you know any articles on foreach loop container that loops over a dataflow task...pls tell me....
thanks in advance,
View 2 Replies
View Related
Sep 17, 2015
I use a ForEach Loop Container in a ssis Package. The package has to look up in the directory 'f:ackups' for backupfiles and copy them into another folder.In my development environment it works fine. But if I run it on the SQL-Server with the SQL-Server Agent, the package logs always that the folder ist empty.Unfortunately the message is always 'empty folder' even if I define 'f:labla' as folder that actually not exists!
As filespecification I tried both *.* and *.bak .My assumption is, that the SQL-Server agent has not enough rights for that folder. But on the other side the agent is able to create backup-files in this folder.The SQL-Server Agent works under netservice control.
View 6 Replies
View Related
Oct 27, 2006
Does anyone know how to change the task name displayed within a ForEach Loop Container (or of the ForEach Loop Container task itself) based on a variable. I am pretty familiar with setting variable values during task execution and using expressions to alter task properties based on variables. I have tried using an expression to alter the value of the Name property of the ForEach Loop Container but the name of the ForEach Loop Container does not change during execution. Since the color of the various tasks change during execution, I would think that the task names could be changed as well.
View 7 Replies
View Related
Jun 5, 2006
I have a package that runs fine by itself. But when I run it inside a Foreach Loop container on a parent package, I got a buffer error after a few loops. Here are a couple of the error lines:
A buffer failed while allocating 49085616 bytes.
The attempt to add a row to the Data Flow task buffer failed with error code 0x8007000E.
I already played around with the Data Flow task€™s DefaultBufferMaxRows and DefaultBufferSize properties, and I am still getting the error. Just wondering if there is a memory leak or something with the Foreach Loop task. I haven€™t install SP1. Maybe SP1 fixes this issue?
View 3 Replies
View Related
Jan 18, 2008
Can anyone tell me how to capture the return code of a process launched by an Execute Process Task? I am able to capture the output by using the StandardOutputVariable but can't seem to capture the actual code.
View 4 Replies
View Related
Jul 22, 2006
I have an Execute Process Task within my package that executes a BCP command which outputs the resultset of a query to a file in the network share. It works fine most of the time, however sometimes for unknown reasons, the following error message gets logged in my log table -
In Executing "c:Program FilesMicrosoft SQL Server90ToolsBinncp.exe" "Select Comments, SoldToCustomerNbr, ProductGroupingCode, ProductGroupingName, RevSumCategoryCode, RevSumCategoryName, ValidFromDate, DTSCollectPct, DTSPrepaidPct, DTSPickUpPct, DCCollectPct, DCPrepaidPct, DCPickUpPct From ShipmentTypeCustomerBlend" queryout \xxxLOGShipmentTypeCustomerBlendLog_060719201440.txt -c -t" " -SDummyServer -T -e"d:SSIS Error LogsJob ExecutionBcpErrors.log" at "", The process exit code was "1" while the expected was "0".
The above error was captured from the System::ErrorDescription variable, by the error event handler, that was attached to the Execute Process Task. This error does not help me to debug the issue.
On running the below statement from the command prompt, i get the actual error message, which is the expected behavior -
"c:Program FilesMicrosoft SQL Server90ToolsBinncp.exe" "Select Comments, SoldToCustomerNbr, ProductGroupingCode, ProductGroupingName, RevSumCategoryCode, RevSumCategoryName, ValidFromDate, DTSCollectPct, DTSPrepaidPct, DTSPickUpPct, DCCollectPct, DCPrepaidPct, DCPickUpPct From ShipmentTypeCustomerBlend" queryout \xxxLOGShipmentTypeCustomerBlendLog_060719201440.txt -c -t" " -SDummyServer -T -e"d:SSIS Error LogsJob ExecutionBcpErrors.log"
Expected Error Message -
Unable to open BCP host data-file.
This error message indicates that either the network path - \xxxLOG is not available for the output file creation or the file - \xxxLOGShipmentTypeCustomerBlendLog_060719201440.txt could not be created for some reason.
I 've tried to capture the error message from the StandardErrorVariable and the StandardOutputVariable properties of the ExecuteProcess Task, but in vain.
Is this a bug ? If so, is there a way to get the actual error message from the task ?
Thanks,Reni
View 5 Replies
View Related
Nov 7, 2007
I have an Execute SQL Task that reads columns as strings but can be null. I feed the information in the result set to a foreach loop container and when nulls are encountered the package dies there. Is there an easy way to deal with this other. I have changed all of my null possible columns to object types but I don't want to do this for all of the possible null columns.
Thanks
View 11 Replies
View Related
Jun 19, 2015
How to capture execute sql task results.
Example if the execute sql task runs select statment (select * from table)means , how do i capture into sql table.
View 10 Replies
View Related
Jul 10, 2007
Hi all,
I got this problem and before post I've read many post similar in the forum (sorry for my english I try to do my best....i'm italian)
This is my scenario.
1) SQL
SELECT
UPPER(SUBSTRING(FileImportazione, 7, 50)) AS str,
Id
FROM Sources
WHERE (TipoImportazione = 0)
This is an SQL task and from this I create a Object variable "ObjDs" on scope package1
2) I introduce a loop (Foreach ADO Enumerator) on my object variable "ObjDs".
Here I mapping two variables "IDsources" and "str" (as you caqn see from my first sql)
Now I set a breakpoint into the beginning of my cicle and really see the dinamic change of the values from "watch" windows.
Now start my problem.
Into this loop I must do "X" operation....but first of all I must Update a table...so I simple SQL TASK...on the dinamic ID of my variable.
Ok, I put a SQL tast into the loop, set SQLsourceType = Variabile, resulset = none, and create an expression like this (SQLstatementsource):
"UPDATE New_pangea.dbo.Sources SET InAggiornamento = "+ (DT_WSTR, 4) @[Utente::IDsources]
If I don't cast (DT_WSTR, 4) I got always an error...
The data types "DT_WSTR" and "DT_I4" are incompatible for binary operator "+". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.
Attempt to set the result type of binary operation ""UPDATE New_pangea.dbo.Sources SET InAggiornamento = " + @[Utente::IDsources]" failed with error code 0xC0047080.
so I put and validate myexpression.
before my global variable @[Utente::IDsources] change the value to true of EvalutateAsExpression.
Something goes always wrong...When I try debug...this is the error
Errore in Execute SQL Task: Failed to lock variable "UPDATE New_pangea.dbo.Sources SET InAggiornamento = 0" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".
Errore in Execute SQL Task: There were errors during task validation.
(Microsoft.DataTransformationServices.VsIntegration)
Hope someone can help me, thanks Alen
View 2 Replies
View Related
Apr 24, 2006
hi guys,
i'm trying to do a bulk insert through a t-sql which accepts 3 params.
i frist run a SQL statement to get a list of DB's to update through a SQL task, then i save the output to a variable object. which is been used by the For each loop.
i've done the mapping with the object fine. but i want to call a SQL task within for each loop, and parse the above results as parameters. i tried parsing it as
exec mysp3 @[User::fundid], @[User::dbCode], @[User::subfund]
where fundiid, dbcode and subfund are user defined variables that gets updated by the ado recordset.
this fails with the error msg:
SSIS package "SP test.dtsx" starting.
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "exec ConnectODBC @[User::fundid], @[User::dbcode], @[User::subfund] failed with the following error: "Incorrect syntax near 'User::fundid'.". 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
Warning: 0x80019002 at Shred the contents of the variable: The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "SP test.dtsx" finished: Failure.
i also tried
exec mysp3 ?, ?, ?
then mapping the inputs still doesn't work
same thing with
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "exec ConnectODBC ?,?,? failed with the following error: "Syntax error, permission violation, or other nonspecific error". 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
View 3 Replies
View Related
Apr 22, 2008
Hello
I have a question
How is foreach loop container - foreach ADO enumerator performace in SSIS package compares to use of cursors in stored procedures
Is there any articles comparing them
I understand a lot of factors can affect the performance, however what is expected performance for the foreach ADO enumerator loop for large dataset. What is Microsoft recommendation for that - recommended - not recommended (using large datasets - over million records)
Thank you
Arminr Bell
View 4 Replies
View Related
Apr 11, 2007
Hi,
I have no "Foreach File Enumerator" oprtion in the Enumerator Property of the Foreach Loop Component.
I have this enumerator in the c:Program FilesMicrosoft SQL Server90DTSForEachEnumerators folder.
Also I check it in the GAC - it does not here. I try to execute gacutil.exe -iF ForEachFileEnumerator.dll, but it is failed with "Failure adding assembly to the cache: The module was expected to contain an assembly manifest." Seems it is not managed enumerator.
Please help me.
Also information on how to regeister unmanaged enumerators are welcome!
View 3 Replies
View Related
May 3, 2007
Okay, can someone explain why when I execute children packages within a loop that only a couple of them work?
When I first started this I had Child Package 1 and Child Packge 2 working from the Parent Package 1. It would loop through twice (I had 2 organizations in my outer loop) and pass in the Parent Package variables correctly.
I am using a simple "Foreach Item Enumerator" with a collection of string enumerators that are the Names of the children packages - these are assigned to a variable that is scoped to the outer loop.
Now, when I add a new Child Package 3 and set it up the same as the other 2, when it goes to execute Child Package 3 it fails with the error:
"Error: The connection manager "[My Package Name].dtsx" is not found. A component failed to find the connection manager in the Connections collection. "
What in the world have I done? I was under the assumption that since the first 2 packages worked, that any other packages I added would work the same.
View 3 Replies
View Related
Feb 15, 2008
Hi, I'm trying to loop thru a table and insert records into another table in ssis. So far I have been able to get the data using a execute sql task set up to store the full result set into a variable called data. I then drug a foreach loop container out and selected the foreach ADO enumerator and used my variable data as the ADO object source variable. I then set up a new variable under variable mappings with index 0 to get the collection values. How do I take that variable and update another table using another sql task inside the foreach loop container? Is this possible?
thanks,
View 8 Replies
View Related