Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Powershell: add a column to a datatable

$
0
0

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).


Viewing all articles
Browse latest Browse all 12963

Trending Articles