How do I use dynamic T-SQL in Lookup? RRS feed

  • General discussion

  • [This is just for sharing information for those common asked questions collected from forums. If you have any better way or feedback, please directly reply in this thread so that community users can benefit from your answers.]


    Is there any way I can change a T-SQL query in a Lookup component during runtime?



    1. Create a package scope variable "SQLVariable", change its type to string.

    2. Open the Lookup transformation, type a default SQL clause for it.

    3. Select the data flow task that includes the Lookup and go to its properties. Click on the ellipsis (…) against Expressions, use the expression "@[User::SQLVariable]" for [LookupName].[SqlCommand] property.

     Then you can dynamically change the SQL clause for the Lookup by modifying the value of the variable "SQLVariable".


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, June 18, 2010 7:03 AM