Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server Powershell-从存储过程返回结果_Sql Server_Powershell_Stored Procedures - Fatal编程技术网

Sql server Powershell-从存储过程返回结果

Sql server Powershell-从存储过程返回结果,sql-server,powershell,stored-procedures,Sql Server,Powershell,Stored Procedures,我在SQL Server 2012中有一个存储过程,当它运行时,它返回一行3列 在powershell中,我可以将数据返回到数据表中 $sqlConnection.Open() $sqlCommand = New-Object System.Data.SqlClient.SqlCommand $sqlCommand.Connection = $sqlConnection $sqlcommand.commandtext = "GetPlantLoadFactor" $sqlCommand.Com

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

在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的值字段。是否有更好的方法来执行此操作,以及如何将65.89的值返回到变量
$PLF

您可以尝试使用行

$table.Rows[0].Value

这很有效,谢谢你。您需要将答案中的$PLF修改为$table