title: BCP update database table base on output from powershell
body: <p>I have 4 files with the same csv header as following <br></p>
  
  <pre><code>Column1,Column2,Column3,Column4 
  </code></pre>
  
  <p><br>
  But I only required data from <code>Column2,Column3,Column4</code> for import the data into SQL database using <code>BCP</code> . I am using the PowerShell to select the columns that I want and import the required data using <code>BCP</code> but my powershell executed with no error and there are not data updated in my database table. May I know how to set the <code>BCP</code> to import the output from Powershell to database table. Here are my powershell script <br></p>
  
  <pre><code>$filePath = Get-ChildItem -Path 'D:\test\*' -Include $filename
  $desiredColumn = 'Column2','Column3','Column4'
  
  foreach($file in $filePath)
  {
    write-host $file
   $test = import-csv $file | select $desiredColumn
   write-host $test
   $action = bcp &lt;myDatabaseTableName&gt; in $test -T -c -t";" -r"\n" -F2 -S &lt;MyDatabase&gt;
  }
  </code></pre>
  
  <p><br>
  <br>
  These are the output from the powershell script <br><br></p>
  
  <pre><code>D:\test\sample1.csv
  @{column2=111;column3=222;column4=333} @{column2=444;column3=555;column4=666}
  D:\test\sample2.csv
  @{column2=777;column3=888;column4=999} @{column2=aaa;column3=bbb;column4=ccc}
  </code></pre>