Subqueries on SSIS Packages

  • Hi,

    I'm having the with SSIS related to subqueries.

    I need to add a parameter into my subquery and in some cases this is extremely important and there is no way to create the query without the subquery.

    Does anyone has any idea?

    Below, follow a query example about what I'm talking:

    select *

    from tableA a

    where exists (Select ID

    from tableB b

    where b.ID = A.ID

    and b.Date = ? )

  • Hello Carlos,

    I'm not sure b'coz I'm at the initial stages on SQL Server 2005.

    Go through this link, may be it gives you the required solution

    http://msdn2.microsoft.com/en-us/library/ms140355.aspx

    Thanks and have a nice day!!!


    Lucky

  • OK, this works for a simple query. However, if you have a parameter on a subquery, it doesnt work...

    That is my problem...

  • Sounds lilke you need to build your entire query in a Scripting Task and put the query in a variable.  Then set the SQLSourceType property of your Execute SQL Task to "Variable" instead of "Direct Input" and put the variable name in the SourceVariable property.

  • Sounds lilke you need to build your entire query in a Scripting Task and put the query in a variable.  Then set the SQLSourceType property of your Execute SQL Task to "Variable" instead of "Direct Input" and put the variable name in the SourceVariable property.

  • well, that is my problem... the variable accepts only 4k characters and the query component 8k. My query, however, goes over 4k, so I cannot use a variable.

    Tks

  • Have you tried splitting your query across 2 or more variables and then concatenating them together using the Expression syntax on the SQLStatementSource property?

  • Hi howeld,

    I think this is not going to work either. An Expression can return at maximum 4000 characters in a single string (DT_WSTR), otherwise it raises a truncation error, saying that it exceeds the max length (4000). Any other ideas?

    Best Regards,

    Henrique

  • Are you doing this in the Control Flow design screen or are you down in a data flow?  Package variables don't have a 4k limit. That only applies to fields in a data flow.

    What is preventing you from designing the query in a Script Task (control flow screen) and then using that variable in your OLEDB data source (or whatever source your are using) for your data flow?

    I need more information as to exactly where you are doing this to fully answer your question.

Viewing 9 posts - 1 through 8 (of 8 total)

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