Sql server Powershell-从存储过程返回结果
我在SQL Server 2012中有一个存储过程,当它运行时,它返回一行3列 在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
$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