How to loop through multiple SQL Tables in SSIS using Foreach Loop?

Anjali Shah 21 Reputation points
2022-01-11T11:26:02.77+00:00

I want to export data from multiple SQL tables to .csv file in SSIS using Foreach loop Container.

How do I achieve the same?

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,464 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 33,386 Reputation points
    2022-01-12T06:48:35.297+00:00

    Hi @Anjali Shah ,

    You may use Script Task for a try as shown below.

    https://stackoverflow.com/questions/6216486/exporting-data-from-multiple-sql-tables-to-different-flat-files-using-ssis-scrip

    You may also use SSIS, Biml, and BCP to meet your requirement.

    Check this link: https://www.mssqltips.com/sqlservertip/6010/export-multiple-sql-tables-to-text-files-using-ssis-biml-and-bcp/

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Olaf Helper 41,021 Reputation points
    2022-01-13T07:00:38.177+00:00

    The standard way is to create a data flow task for each table & destination file; one by one.

    Dynamically?
    See your other post, it's the same, just the other way round.
    https://learn.microsoft.com/en-us/answers/questions/692361/how-to-create-table-dynamically-in-ssis-using-the.html

    0 comments No comments