Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Powershell help for SQL Resultset

$
0
0
I need some help ... I find myself somewhat perplexed. Yet this should be easy.
So I execute a stored procedure from within a powershell function.

Quote:

function Stats-Query($SQLServer){
invoke-sqlcmd -query "EXEC SPROCNAME" -database DATABASENAME -serverinstance $SQLServer
}

$Results = Stats-Query $MachineName
The SPROC is dynamic and will make new column names, based on db names etc. This all works fine and puts results into $Results

results will be x columns across (unknown name, or quantity).
results will be ONE row.

I want to write out
ColumnName = VALUE from the results

How can I tweak this part of my code?
Remember, my results are stored in $Results


Quote:

foreach($Column in $Results)
{
echo $Column + " = " + $Value
}

Viewing all articles
Browse latest Browse all 13329

Trending Articles