title: Exporting empty tables from multiple SQL tables to csv format
body: <p>How do I get to export blank tables (i.e. just the headers) as well as tables containing data. The reason for the blank table is my customer wants to import the table structure i.e. the headers so it can be used in the future if needed. </p>
  
  <p>When I follow the solution on: <a href="https://stackoverflow.com/questions/6216486/exporting-data-from-multiple-sql-tables-to-different-flat-files-using-ssis-scrip">Exporting data from multiple SQL tables to different flat files using SSIS Script Task</a> I get the below error: </p>
  
  <blockquote>
    <p>Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at ST_97b3989b700a41f1ad54fb2abd27b891.vbproj.ScriptMain.Main() --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()</p>
  </blockquote>