x
login about faq Site discussion (meta-askssc)

SSIS Flat File Export

Can someone point me in the right direction for building a flat file? I have to build a flat files made up of fields based on a source codes. I can have up to 10 different source codes and need to export the records from a table based on the source code. Ex: 1st flat file will be named sourcecode1, 2nd flat file sourcecode2, etc. Script is: Select * from table1 where sourcecode = 'sourcecode1' for first flat file and then Select * from table1 where sourcecode = 'sourcecode2', etc. Is there a way to make the table a variable and then have SSIS loop through all sourcecodes in the table building each flat file. I have the package set up now where the sourcecode is a variable but I have to change this variable each time as well as the name of the flat file. I would like an automated approach where it reads all sourcecodes and exports data for each flat file based on this criteria. Thanks!

more ▼

asked Oct 11 '11 at 08:45 AM in Default

redder gravatar image

redder
158 6 15 21

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You'll need a for/each loop container with a variable for the current sourcecode. The loop will have the flatfile output which you'll need to configure with an expression for the filename so you can get the sourcecode into the file name.

Here is an almost exact step by step walk-through of what you're looking to do - http://bi-polar23.blogspot.com/2008/02/dynamic-flat-file-destinations.html

more ▼

answered Oct 11 '11 at 09:41 AM

KenJ gravatar image

KenJ
12.4k 2 10

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x751

asked: Oct 11 '11 at 08:45 AM

Seen: 375 times

Last Updated: Oct 11 '11 at 08:45 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.