# How to Use powershell to execute output of a Stored Procedur

**URL:** <https://forums.powershell.org/t/how-to-use-powershell-to-execute-output-of-a-stored-procedur/1431>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/how-to-use-powershell-to-execute-output-of-a-stored-procedur/1431 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/how-to-use-powershell-to-execute-output-of-a-stored-procedur/1431/1 "2011-12-31T18:30:00Z")

</div>

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  
>   
> $shape1=$page.DrawRectangle(7.81250000000,6.78,8.29166666660,7.025);

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?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:03pm UTC](https://forums.powershell.org/t/how-to-use-powershell-to-execute-output-of-a-stored-procedur/1431/2 "2024-05-16T21:03:30Z")

</div>


