Reputation: 1181
This is what I have been trying to do:
SSIS package : Items
With the following sql statement, using linked server:
USE [TARGET]
GO
INSERT INTO [dbo].[Item]
([No_]
,[Description]
,[Unit Price]
)
SELECT [No_]
,[Description]
,[Unit Price]
FROM [SOURCE].[Database].[dbo].[Item]
What I want to do:
Store the datasource for both TARGET and SOURCE in sql table Datasource:
Data Source=localhost;Initial Catalog=TARGET;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;
Data Source=localhost;Initial Catalog=SOURCE;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;
And finally update the sql statement in the SSIS package pointing at a parameter.
INSERT INTO @SOURCE +'.[Item]'+
([No_]
,[Description]
,[Unit Price]
)
SELECT [No_]
,[Description]
,[Unit Price]
FROM @SOURCE +'.[Item]'+
But not been successful so far, any suggestions?
Update:
Was missing one picture:
In the connection manager I would want to get the datasource information from the table Datasource (first picture after "what I want to do")
Update 2:
Is this possible??
Upvotes: 0
Views: 443
Reputation: 12271
You can try this in Execute SQL Task
:-
DECLARE @query nvarchar(max)
DECLARE @TARGET nvarchar(200) = ?
DECLARE @SOURCE nvarchar(200) = ?
Set @query ='INSERT INTO ' + @TARGET +'.[Item]
([No_]
,[Description]
,[Unit Price]
)
SELECT [No_]
,[Description]
,[Unit Price]
FROM ' + @SOURCE +'.[Item]'
EXEC(@query)
In the Parameter Mapping
map the ?
to the variables created ie Target and Source
Upvotes: 2