0

I have Import.csv file,

First column values --> table names which are already exists in target database.

Next two columns [Desc],[Code] data gets populate from CSV file to table.

TABLE_NAME  DESC    CODE
tab1       table1   A
tab1       table1   B
tab1       table1   C
tab2       table2   D
tab2       table2   E
tab2       table2   G...

In this scenario, how to load tab1 data into the same table in destination and so on.

Which way will be more standard to accomplish this task? If its a script task using C#, kindly give me a clear script to identify a value changes in the first column.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
ScriptGuy
  • 101
  • 3
  • 12
  • Have you looked at using a data flow with a conditional split into separate table destinations? – Neil P Jun 10 '15 at 09:25
  • Yes,Initially I was thought of implementing in that way. But I'm bit confused about conditional split. Can you tell me, how we can split the records based on first column values(i.e. table names)? – ScriptGuy Jun 10 '15 at 10:18
  • you write a condition (i.e. TABLE_NAME = "tab1") and give the output a name (myTab1Output). Join the conditional split block to a destination and you will get a drop down asking which output to use. Only the rows matching the condition appear, so you can safely repeat this for each table you want to write to. – Neil P Jun 10 '15 at 10:20
  • Actually this is not an static file. If the table names are increased in the future, do i need to manually update the package(i.e. TABLE_NAME ="newtable"? Or Will it take care dynamically? – ScriptGuy Jun 10 '15 at 11:09
  • ah, in that case, you would indeed have to add more. If every table has the same schema, you could probably rig up something using a combination of a loop and a variable table name in the data flow. – Neil P Jun 10 '15 at 11:13
  • Here table schema will be same for all the tables. But the challenging part is how to create the flow between source and destination using the first column "TABLE_NAME". Does this make any sense? Is it possible to implement? – ScriptGuy Jun 10 '15 at 11:20
  • you could use a loop that sets the table name via a variable and filter based on that in the data flow inside the loop – Neil P Jun 10 '15 at 11:38
  • I am planning to create a temp table and load all the TABLE_Name values into that. Then I will take distinct value from that table and loop each records match the distinct value.Do you see any issue on this approach? Instead of using temp table, any other alternative solutions? – ScriptGuy Jun 10 '15 at 11:52
  • Off the top of my head, I cant think of anything better. Sounds like that should work. – Neil P Jun 10 '15 at 11:59
  • You could write a stored proc that receives the three columns as parameters and executes dynamic SQL. Then call it from your dataflow with an Execute SQL component. – Tab Alleman Jun 10 '15 at 18:56

0 Answers0