sql server - loop over company names ssis 2008 -
i have tables navision names
dbo.[companyname$cust_ ledger entry].[customer no_] i have 30 companies . looking loop on companies follow solution https://social.msdn.microsoft.com/forums/sqlserver/en-us/a13d39ab-968b-41f2-bf85-cb46db763d4e/variable-to-dynamically-change-tablename-for-data-flow-task
but how can use in data flow task ? how can change table names dynamically ?
ok can see other post have attempted things rather asking how something, give hand.
here example of how can this:

here example of ssis package.
for starters need 3 variables:

two string variables i've called them companyname , sqlstatement , object variable i've called companylist.
we first of need populate companylist, in execute sql task.

we need set result set "full result set", in sql statement need add way of getting full company names, instance "select distinct name dbo.company", here store these results in object variable:

this store results object variable.
we need setup our sqlstatement variable. variable string variable need set "evaluateasexpression" - "true":

in expression need enter following:
"select * dbo.[" + @[user::companyname] + "$cust_ ledger entry].[customer no_]" now setup can on foreachloop.

set foreachloop above, want evaluate "rows in first table" against "companylist" object variable.
the next step map our final variable "companyname" used in out sql expression:

in foreachloop go variablemapping tab , enter select "companyname" variable index 0, change "companyname" variable each time loop runs, changing sql statement variable allowing loop through each of companies.
the final step go dft , setup oledb source:

for oledb source need select "sql command variable", here select "sqlstatement" variable.
you can carry on dft wish.
Comments
Post a Comment