title: how to create a SSIS package which creates three text files, using same variables but the textfile is only created when the correct data is found?
body: <p>There are only 3 files that can be created : "File_1", "File_2" and "File_3". The same variable name is used in each instance (User::FileDirectory) and (User::File_name), but because the actual value of the variable changes, a new file is created.However the files are only created if there is data to go into the file. i.e. if there are no records to populate the file, it will not be created at all. When the files are created, the date the file was created should also be added to the filename. eg: File1_22102011.txt</p>
  
  <p>Ok if the above was a little confusing, the following is how it works,</p>
  
  <p>All the files use the same variable, but it is reset before each file is created. </p>
  
  <p>• So it populates a result set in memory with the first sql selection (ID number, First_Name and Main_Name). It sets the file variable to “File_1”. If there are records in the result set, it creates and writes to this filename.</p>
  
  <p>• Then it creates a new result set with the second selection(Contract No). It sets the variable to "File_2". If there are records in this new result set, a new file will be created from the variable(which now has a new value)</p>
  
  <p>• Finally a third result set is created (Contract_no, ExperianNo, Entity_ID_Number, First_Name, Main_Name), and the file variable is set to "File_3". Again if there are records in the result set, then this file will be created and written to.</p>
  
  <p>I have worked on a few methods to achieve this but they all have failed, So little help will be greatly appreciated. </p>