I want to try to do a bulk insert to a sql table.
I found an article at bulk-copy-data-sql-server-powershell
that discusses using a DataTable as a source. I've never worked with DataTables before.
I've saved the data as a CSV that has the same column names as the destination table.
So it looks like I need to create the DataTable first:
$a = New-Object System.Data.DataTable
$a | Get-Member
But when I run Get-Member it tells me "You must specify an object for the Get-Member cmdlet." I thought the New-Object statement would have created an object.
Then I need to populate the object. I was hoping something like
Get-Content filename.csv could be piped into the DataTable.
Do I need to define columns for the DataTable first?
Then how can I populate the DataTable from the CSV?
Thanks in advance for any assistance.
Christian Bahnsen