|
Posted by Erland Sommarskog on 08/21/07 21:24
(gelangov@hotmail.com) writes:
> I have 2 variables, one is the column name of the table and the other
> one is the table name and I need to write this in the "Execute SQL
> task" of a "For each loop" container in a ssis package like this:
>
> Truncate table <tableName>
> Insert into <tableName>
> Exec (' select [' + ?+ '] from '+ ?)
>
> It gives me error message when I try run the ssis. However if I put
> the above statements into a stored procedure and wrote look this, it
> works:
>
> spStroedproc ?, ?
>
> Do I need to change any of my settings for my "Exec" to work?
I don't know SSIS per se, but you can never parameterise on a table
name in SQL Server. You need to build the entire query string.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|