Unable to use package variable in ssis script

  • I have a package variable which consists of the table name (created from GUID provided). In my script component I have to insert values into this table. As i don't know the table name, I am trying to refer this variable but, not working. I have tried declaring readvariable for the script, declared variable in the script to get the values from the package variable but nothing is working. I appreciate your help.

  • radb4u (7/21/2011)


    I have a package variable which consists of the table name (created from GUID provided). In my script component I have to insert values into this table. As i don't know the table name, I am trying to refer this variable but, not working. I have tried declaring readvariable for the script, declared variable in the script to get the values from the package variable but nothing is working. I appreciate your help.

    Could you provide additional information?:-)

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Thank you for the reply. I have declared a package variable User::TableName which holds the tablename created from GUID (ex: tbl4e0dfc2c8389488ca2d050c202233871). It is runtime so we don't know each time what will be the table name. Now, I have a script component in my package which loads data into this table. I am unable to refer the tabel name in my sql command (ex: insert into @[User::TableName] values ......). Hope it is clear.

  • radb4u (7/21/2011)


    Thank you for the reply. I have declared a package variable User::TableName which holds the tablename created from GUID (ex: tbl4e0dfc2c8389488ca2d050c202233871). It is runtime so we don't know each time what will be the table name. Now, I have a script component in my package which loads data into this table. I am unable to refer the tabel name in my sql command (ex: insert into @[User::TableName] values ......). Hope it is clear.

    ok, sounds to as if your not setting the dynamic properties.

    I hope that the following article gives some insight on property expressions and is helpful in resolving your issue.

    http://www.simple-talk.com/sql/ssis/working-with-property-expressions-in-sql-server-integration-services

    You should share what objects and your code to help us help you.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I don't think you can use a parameter like that directly. I think the parameter substitution is limited to the where clause. I have gotten around that in the past by building an entire SQL command and using the SQL Command from Variable option. Keep in mind that to do design work you need to fill the variable in with at least a dummy command that returns the proper meta-data.

    CEWII

  • That sounds good. I have used the following code now in preExecute:

    VariableDispenser.LockForRead("User::TableName")

    Me.VariableDispenser.GetVariables(vs)

    TName = vs("User::TableName").Value.ToString

    And used TName in the query. It worked and loaded the data into the table but, color of the control flow task is still yellow. It suppose to turn into green when it is done. I checked the data flow tasks those are all green. What does it mean, it is still running the task?

  • Never mind, I forgot to unlock the variable 'vs'. If any user needs the code I declared the variable as 'Dim vs As IDTSVariables90'.

    Thanks

Viewing 7 posts - 1 through 6 (of 6 total)

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