Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Add columns to PowerShell array and write the result to a table

$
0
0
Hi,

I have one more question about PowerShell.

I have this code to execute a stored procedure.

  $SqlSourceConnection.Open()
  $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
  $SqlCmd.CommandText = "EXECUTE dbo.MyStoredProcedure"
  $SqlCmd.Connection = $SqlSourceConnection
  $SqlCmd.CommandTimeout = 30
  $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
  $SqlAdapter.SelectCommand = $SqlCmd
  $Data = New-Object System.Data.DataSet
  $SqlAdapter.Fill($Data)
  $SqlSourceConnection.Close()
  $Data.Tables[0]

Now I would like to add two columns (server name and timestamp) to the resultset in PowerShell, and then write the result to a table on another server. (I cannot modify the stored procedure.)

What method would you recommend to do this? All feedback is greatly appreciated.

Best regards

Ola Hallengren
http://ola.hallengren.com

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>