Hi,
I have PS code that reads csv file into an array using
$file = Import-Csv $edifile
$OrderInfo += $file | Where-Object {$_."Issue Date" -eq $Datearray[$i]} | Select-Object "Order Number"
Which means I can then reference elements of the array based on their column headings.
I am trying to get to the same result using a SQL query
## - Connect to SQL Server using non-SMO class 'System.Data':
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection;
$SqlConnection.ConnectionString = `
"Server = $SQLServer; Database = $Database; Integrated Security = True";
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand;
$SqlCmd.CommandText = $("EXEC [schema].[ReboundHeader]");
$SqlCmd.Connection = $SqlConnection;
$SqlCmd.CommandTimeout = 0;
## - Extract and build the SQL data object '$DataSetTable':
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter;
$SqlAdapter.SelectCommand = $SqlCmd;
$DataSet = New-Object System.Data.DataSet;
$SqlAdapter.Fill($DataSet);
$DataSetTable = $DataSet.Tables["Table"];
The output from sql in VS does not look the same as the CSV file import.
How do I output the SQL into an array which I can then reference the same way as the CSV import?
TFH