Creating Db Tables with Foreach Loop

  • Ran into this the other day on a different task, but same error. It's the generic "We couldn't be more specific error, sorry." error.

    A couple of questions. First, are your sheets all starting with an alpha character? A table can't start with a non-alpha char. This is the reason you got the error earlier with the zero.

    Second, can you confirm that the Execute SQL task is the one that it's failing on? I just want to make sure.

    Third, can you post the screenshot of your foreach setup? Of course, blank out anything necessary.

    Fourth, can you try putting in a script task instead of the ExecuteSQL? What you'll want to do when you open it is under ReadOnly Variables, type in "WorksheetName" (I think that's your variable name, without the User:: part), Then click edit script in the bottom right. In the window that pops up, edit the small green area that says 'insert your code here', removing the ' in front of that line, and replacing it with MsgBox ( CSTR( dts.variables("WorksheetName").value)).

    What this will do when you run it next is give you a pop up with what it THINKS worksheetname is being populated with through the loop. That will help us nail down the problem.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • The way variables are handled depends on what connection type you are using.

    Variables inside OLE are referenced using ?

    Variables inside ADO.NET are referenced using the @VariableName set-up in Parameter mapping.

  • Hey.. sorry its taken a while to reply I had to figure out adding watches to packages (I wasn’t kidding when I said I was new to this!)…

    The variable almost as I expected.. The first worksheet is called S1_test, and the variable showed as {S1_Test$}... when I changed to a script task the text box returned S1_Test$

    I've added screen shots of the foreach loop set up...hopefully this will shed some light.

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply