How to Use powershell to execute output of a Stored Procedur

by apriljuly at 2012-12-27 02:33:05

I wrote a stored procedure, the stored procedure can display some command to draw a report. Now I want to use powershell to execute each row of the output of the stored procedure.

I have a code like this

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection <br>$SqlConnection.ConnectionString = &quot;Server=T420s-JLI-W7;Database=AMSNewDataWarehouse;Integrated Security=True&quot; <br>$SqlCmd = New-Object System.Data.SqlClient.SqlCommand <br>$SqlCmd.CommandText = &quot;YQBreport1&quot; <br>$SqlCmd.Connection = $SqlConnection <br>$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter <br>$SqlAdapter.SelectCommand = $SqlCmd <br>$DataSet = New-Object System.Data.DataSet <br>$SqlAdapter.Fill($DataSet) <br>$SqlConnection.Close() <br>$DataSet.Tables[0]

However it only list the output, instead of execute each row of the output. How can I let it execute each row of output?
An example of the output row is like

by Klaas at 2012-12-27 04:57:05
I don’t understand what you want to do. In general, calling a stored procedure with Powershell lets SQL Database engine execute the SP.
You create reports by making an .rdl file in Visual Studio. This file is then deployed to Report Server.
Do you want to create the report definition with Powershell? Or do you want to draw those shapes somewhere outside Report Server?