Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Trying to use an input variable inside a ForEach

Author  Topic 

kissa49
Starting Member

10 Posts

Posted - 2010-06-28 : 16:42:33
I am trying to use a variable as an input in an 'Execute SQL Task'.
I pre-set my object outside the ForEach container. In the foreach container I set up all the Variable Mappings. I know all that is done correctly because when I use a Script Task to output these parameters to the screan it works.
But when I set up my 'Execute SQL Task' with one of these variables in the Variable Mappings as 'Input', with Parameter Name set to 0, and then have this simple script in the SQLStatement:

SELECT NAME FROM SCHDTASK
WHERE ID = ? --@Task_ID

I get an error when I run this.
"[Execute SQL Task] Error: Executing the query "SELECT NAME FROM SCHDTASK WHERE ID = ?" 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.

If anyone has any idea what I am doing wrong here, I would really appreciate any kind of input.

Thank you!
   

- Advertisement -