I need to create and populate a table on sql server db, starting with an array of powershell objects from select-object . I need to create a table with the correct data types and fields.
One way that I know well is export-csv and then invoke-sqlcmd with BULK INSERT , but I prefer to skip csv export.
How is invoke-sqlcmd usually used to create / populate a table, starting with an array of hash tables? Did you know that other methods do the same job without using invoke-sqlcmd ? Do I need to use System.Data ? How?
thanks
EDIT 1: Another possible way is New-Object System.Data.SqlClient.SqlConnection , for which I could ExecuteNonQuery() for each element of the array.
EDIT 2: Another option, always based on System.Data , updates the SqlDataAdapter instance.
source share