• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Script to Output Table as multiple files

Need Script or SSIS package that accept number of files as an argument and then export the table broken into that many files?  
  • 2
1 Solution
The simplest way be to use some kind of paging SP (there are plenty out there). Based on the number of records, and the number of files, work out how many records each file will have. You then have a bunch of numbers that you can use in:

1. A For Each Loop
2. Inside the for each loop, a data flow which calls the paging SP and gets the records

The for each will also need to alter the output file used by the data flow.

Why do you want to chunk it up?
Here's a link to one particular paging solution:


Get that working in Management Studio First, then think about the For Each logic.

You can create package variables and assign them from the command line if you want something that will do this from the command line.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now