USing Variables in SSIS OLEDB Source SELECT statement

  • I want to have a query like below in the OLEDB Source:

    Select @[user:intCount] as Count

    where @[user:intCount] is the SSIS variable.

    Can anybody tell me if I can do this ? Please post the correct syntax if I can do it.

  • You need to create another variable to hold the SQL and then pass the value of the existing variable into that.

    So create a new variable with a string datatype, in the properties set the "Evaluate as Expression" property to true and then edit the expression and do the following (with quotation marks):

    "SELECT "+@[user:intCount]+" AS Count"

    Then in your OLEDB source set the data access mode to "SQL command from Variable", choose your SQL variable and job's a good'un 😉


    I'm on LinkedIn

  • Is the maximum length of the query restricted to 128 characters ?

  • No. What makes you think it might be?

    If you give us more information on what you're trying to do, we may be able to suggest a better way for you to do it. What sort of data does the IntCount variable hold, and what do you do with the output of your query?

    John

  • The maximum length of a variable expression is 4000 as is discussed here: http://consultingblogs.emc.com/jamiethomson/archive/2009/05/27/4000-character-limit-in-ssis.aspx

    Your expression is well under that amount unless your count variable is unbelievably massive in which case I would ask what it is you're trying to achieve (as the other poster asked)?


    I'm on LinkedIn

Viewing 5 posts - 1 through 4 (of 4 total)

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