sql server - SSIS Multiple flat files into tables with Parent Child -


this tables in sql server:

table: customer (custnum pk , auto increments)  custnum  firstname  lastname 123      bob        smith 456      john       paton 789      fred       bloggs  table: job  (custnum fk, jobnum pk , auto increments)  jobnum  custnum   item     desc 852      123      abcde    widgets 654      456      wert     more widgets 987      789      qwe      mouse mat 

i have data coming 2 csv's in below format

table: customer   firstname  lastname bob        smith john       paton fred       bloggs  table: job  item     desc abcde    widgets wert     more widgets qwe      mouse mat 

i need import customers jobs sql tables maintain referential integrity. when job record created, needs lookup correct custnum - how do this? have found many examples doing 1 cs file, not multiple csv's. also, there no reliable key tie job rows customer table - don't think able use ssis lookup - i?

you can use ssis package feed data base.

the package it

main package

enter image description here

enter image description here result customer

custnum     firstname  lastname ----------- ---------- ---------- 1           bob        smith 2           fred       bloggs 3           john       paton 

result

jobnum      custnum     item       desc ----------- ----------- ---------- -------------------------------------------------- 1           1           abcde      widgets 2           2           qwe        mouse mat 3           3           wert       more widgets 

how it:

main task:

  1. add dts customer

  2. add dts job

  3. create flow (green arrow) customer job

customer dts

  1. add connection customer file

  2. add connection customer sql

  3. sort both outputs firstname, lastname

  4. configure merge join task image enter image description here

  5. insert , configure conditional split 1 output called "new" , expression isnull(custnum)

  6. insert customer table

job dts

  1. insert connection job file

  2. insert connection customer table

  3. sort both outputs firstname, lastname

  4. configure join image: enter image description here

  5. insert connection job table

  6. sort both custnum, item

  7. insert , configure conditional split 1 output called "new" , expression isnull(jobnum)

  8. insert job table


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -