title: How can I create a database table from a system.Data.datatable object?
body: <p>Let us assume, that I have the following PowerShell code:</p>
  
  <pre><code>$connectionstring = "... some connection ..."
  $sql = "Select * from Sometable"
  $tablename= 'Copy_of_Sometable' 
  
  $cmd = New-Object system.Data.OleDb.OleDbCommand($sql,$connectionstring)
  $da = New-Object system.Data.OleDb.OleDbDataAdapter($cmd)
  $dt = New-Object system.Data.datatable
  [void]$da.fill($dt)
  </code></pre>
  
  <p>I know, that I can derive a create table script from $dt and use it to create a new table with a given name cf. <a href="https://stackoverflow.com/questions/1104082/programmatically-create-a-sqlce-table-from-datatable">for example</a>.</p>
  
  <p>But is there a more direct way to create a new table with a supplied name (empty or already filled) from the datatable object? </p>