(SSIS) Datenflusstask - Exportieren von SQL in eine Excel-Datei

553
Creek

Ich bin auf der Suche nach einer Lösung / einem folgenden Fall. In der MS SQL-Datenbank habe ich zwei Tabellen (Rechnung, Rechnungsposition). Ich muss Daten exportieren, um zu übertreffen.

Mein Problem ist die Struktur der Export-Excel-Datei.

  1. Erster Datensatz aus der Tabelle "Rechnung"
  2. Bezugsdatensätze aus der Tabelle "Rechnungsposition"
  3. leere Reihe

  4. Zweiter Datensatz aus der Tabelle "Rechnung"

  5. Bezugsdatensätze aus der Tabelle "Rechnungsposition"
  6. leere Reihe

  7. Dritter Datensatz aus der Tabelle "Rechnung"

  8. Bezugsdatensätze aus der Tabelle "Rechnungsposition"
  9. leere Reihe

  10. ...

  11. Letzter Datensatz aus der Tabelle "Rechnung"
  12. Bezugsdatensätze aus der Tabelle "Rechnungsposition"
  13. leere Reihe

Kennt jemand ein gutes Beispiel?

0

1 Antwort auf die Frage

0
Bharat Prasad Satyal

Answer for this question is little tricky.

  • Create two variable called Invoice as object, invoiceId as string (I have supposed this is the linking field between these two table).
  • Now using script task, list invoiceIds from invoice table and store it into Invoice object. In result set result name is 0 and VariableName is User::Invoice.
  • Pull for each loop container and choose ADO enumerator then choose User::Invoice as ADO object. Now go to variable mapping and pass InvoiceID field into User::invloiceId variable.
  • Now add data flow task. Choose three source. One from invloice table, another from InvoiceItem table and another as blank row(Convert using Data conversion if necessary since this is blank row)
  • Now using parameter use invoiceID in where condition on each table.
  • Use union all to do union from all three output.
  • Now choose destination as excel and pass all data into it.

Hope this will solve your problem. Thanks.