sql-serverssisssis-2012execute-sql-task

Not able to recognize a table variable in ssis sp


I have created a variable in ssis called Vpop_summary_table.

I have used this variable in a sql statement.

my variable

Vpop_summary_table

is expected to give value

[dbo].[2019-02-02_pop_table]

It is fine in ssis.

DECLARE @Vpop_summary_table VARCHAR(100)


    SET  @Vpop_summary_table= ?
    SELECT 
          ,[Age Range]
          ,[Gender]
         ,[2023 Population]
     INTO [@Vpop_summary_table]
      FROM [dbo].[2018_Population_Table_CLARITAS]

My table is created as [@Vpop_summary_table] instead of [dbo].[2019-02-02_pop_table]


Solution

  • You cannot pass table name as parameter, you have to use expressions to achieve that:

    Open Execute SQL Task editor, Go To Expressions Tab, add an expression for the SQLStatementSource property as following:

    "SELECT 
           [Age Range]
          ,[Gender]
          ,[2023 Population]
     INTO " + @[User::Vpop_summary_table] + "
     FROM [dbo].[2018_Population_Table_CLARITAS]"
    

    More info at: