I would like to select dynamically column based on rows from another table using SSIS
Exemple : I have table A where I have the names of the column I want to query. So I want to query columns in table B that names are stored in table A.
I found a way to do it in SQL query but I don't know how to do so in SSIS.
DECLARE @columnList VARCHAR(MAX),@sql VARCHAR(MAX)
SELECT @columnList = COALESCE(@columnList+',' ,'') + columnName
FROM [dbo].[tableA]
SET @sql = 'SELECT ' + @columnList + ' FROM dbo.TableB'
EXEC(@sql)
Any suggestion?
Thank you