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:

example_loop_container

here example of ssis package.

for starters need 3 variables:

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.

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:

result_set

this store results object variable.

we need setup our sqlstatement variable. variable string variable need set "evaluateasexpression" - "true":

evaluateasexpression

in expression need enter following:

"select * dbo.[" +  @[user::companyname] + "$cust_ ledger entry].[customer no_]" 

now setup can on foreachloop.

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:

variablemapping

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:

oledb source

for oledb source need select "sql command variable", here select "sqlstatement" variable.

you can carry on dft wish.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -