Hi All,
I am migrating a DTS package to SSIS 2008R2 and I have a situation where i have to iterate through a table and have to load data from a single source table, into multiple Server-DB combinations.
The Server-DB combination is picked up from a table.
The table looks something like,
Name of Table: TABLE_A
____________________________
ID Server-DB Combination
_______________________________
1 SERVER1.DB1
2 SERVER2.DB2
3 SERVER3.DB3
4 SERVER4.DB4
5 SERVER5.DB5
6 SERVER6.DB6
7 SERVER7.DB7
8 SERVER8.DB8
9 SERVER9.DB9
Here is my insert statement in SQL 2000 database:
set @dbname = (SELECT [Server-DB Combination] FROM dbo.TABLE_A)
set @sql =
'INSERT INTO '+@dbname+'.dbo.DESTINATION_TABLE '
+'Select * '
+'from SOURCE_SERVER.SOURCE_DB.DBO.SOURCETABLE '
+'where COLUMN1 > GETDATE() -15 '
+'and COLUMN2 = 'INR'
+'and COLUMN3+COLUMN4+cast(COLUMN1 as varchar(10)) NOT IN
(SELECT COLUMN3+COLUMN4+cast(COLUMN1 as varchar(10)) FROM '+@dbname+'.DBO.SOURCETABLE)'
EXEC(@sql)
Note: The table dbo.DESTINATION_TABLE is available in all the Server-DB combinations and the METADATA of source and destination are exactly the same.
I am assuming a For loop and configure that to iterate a data flow task that has an OLE DB Source with SQL command as a source with the select query from above mentioned query.
But my concern is about the destination coz it is changing dynamically based on the Server_DB Combinations which is also making things complex while mapping source to destination.
Any suggestions please?
Thank you.