Powershell - 从存储过程返回结果

时间:2016-12-08 14:18:06

标签: sql-server powershell stored-procedures

我在SQL Server 2012中有一个存储过程,当它运行时,它会返回一行包含3列。

SP Result

在powershell中,我可以将数据返回到数据表中。

$sqlConnection.Open()
$sqlCommand = New-Object System.Data.SqlClient.SqlCommand
$sqlCommand.Connection = $sqlConnection
$sqlcommand.commandtext = "GetPlantLoadFactor"
$sqlCommand.CommandType = [System.Data.CommandType]::StoredProcedure
$result = $sqlCommand.executereader()
$table = new-object “System.Data.DataTable”
$table.Load($result)
$PLF = $table
$sqlConnection.close() 

$PLF

我想要的只是65.89的Value字段。有没有更好的方法来执行此操作,如何将65.89的值返回到变量$PLF

1 个答案:

答案 0 :(得分:1)

您可以尝试使用行

CloseMainWindow()