admin管理员组文章数量:1391960
When I run this from the PowerShell command line
Invoke-Sqlcmd -TrustServerCertificate -ServerInstance "HELLODANNY\inst0100"
-Database "come" -outputas datarows
-Query "select count(*) from andplaywithus"
I get this output in the terminal.
Column1
-------
74
However when I put the database invocation into a loop
# Define a condition to control the loop
$counter = 0
$maxIterations = 1005 # Number of times to run the query
while ($counter -lt $maxIterations) {
$result = Invoke-Sqlcmd -TrustServerCertificate -ServerInstance "HELLODANNY\inst0100" -Database "come" -outputas datarows -Query "select count(*) from andplaywithus"
Write-Host "Result: $($result)"
# Increment the counter to avoid an infinite loop
$counter++
# Optionally add a delay between iterations
Start-Sleep -Seconds 20
}
I get
Result: System.Data.DataRow
this might work
$result = Invoke-Sqlcmd -TrustServerCertificate -ServerInstance "HELLODANNY\inst0100" -Database "come" -outputas datarows -Query "select count(*)as count from andplaywithus"
Write-Host "Result: $($result[0].count)"
本文标签: databasepowershell invokesqlcmd SystemDataDataRowStack Overflow
版权声明:本文标题:database - powershell invoke-sqlcmd System.Data.DataRow - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744690871a2619987.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论