Hello guys. i am writing the following in the powershell:
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
#$DataSet = New-Object System.Data.DataSet
$Datatable = New-object System.Data.Datatable
$SqlAdapter.Fill($datatable)
$SqlConnection.Close()
$finalDataSet.Merge($datatable)
clear
=======================================================
I would like to add a col to $datatable before I merge it everytime. That col value is from $_ ( the each item loop from the top).