• First take a look at Andy Leonard's blog on dynamic SQL in variables

    http://sqlblog.com/blogs/andy_leonard/archive/2007/07/22/ssis-design-pattern-dynamic-sql.aspx

    In his blog he demonstrates the creation of the dynamic SQL in a variable and then uses a script task to display the resulting SQL. You don't really need to do that, he just did it to show the resulting script. But if you follow his steps to the point of the script task you will have your dynamic SQL built. Looking at your post you may need several variables, and I am not sure how you would distinguish which dynamic SQL variable to call with the information you gave.

    Anyway if you stop just before the script task and then start with your Execute SQL Task. On the General Tab, set your "SQLSourceType" to Variable, and then your "SourceVariable" to the appropriate variable. Everything else in your Execute SQL Task should be pretty much the same as before. One caution though, SSIS variable expressions are limited to 4000 characters. If you have really long SQL statements you may bump into that limit. There are ways around that, but you don't really want to cross that bridge until you need.