• let explain myself

    I want to incorporate the following code in ssis and put the result into RecordSet. Tablename comes from another RecordSet.

    I tried using Execute T-SQL Statement Task and got an error

    SET @[User::c] = ''

    SET @[User::t]=@[User::TableName]

    SELECT @C = @C + c.name + ', '

    FROM syscolumns c INNER JOIN sysobjects o ON o.id = c.id

    WHERE o.name = @[User::t]

    ORDER BY colid

    SELECT Substring(@[User::c], 1, Datalength@[User::c]) - 2)

    error message

    Execute SQL Task] Error: Executing the query "

    SET @[User::c] = ''

    SET @[User::t]=@[User::Tabl..." failed with the following error: "Incorrect syntax near 'User::c'.

    Must declare the scalar variable "@c".

    Must declare the scalar variable "@".". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    OR

    I am trying to insert data from Source DB to destination DB. Here table name should be dynamic.

    Insert Into @DTableName

    (@Columns)

    values

    Select * from @STABLENAME

    In Query detination columns names we should provide. So I have taken @columns variable to return column names with cama seperation

    Declare @Columns varchar(max)

    SET @Columns =(select SUBSTRING(

    (SELECT ',' + s.name

    FROM (select name from sys.columns

    where object_id=(select object_id from sys.tables where type='u' and name =@DTableName

    )) s

    FOR XML PATH('')),2,200000) )

    While I parse this expression in Execute SQL SQL Source Staatement expression editor I am getting this Error:

    [Execute SQL Task] Error: Executing the query "insert into dbo.Test(@columns )selec..." failed with the following error: "Must declare the scalar variable "@column".". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    If I get any help from either request, then that would be great