Hi
I have one issue that 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.
can any one give solution for this....
Ram