Chand00 (7/25/2014)
I want to find out number of columns returned from a query in a powershell script.As we will be passing a dynamic query which can retrieve only 2 columns or 5 columns or n columns based on user's choice.
$SQLQuery = " select * from sysdatabases "
$QueryResults = Invoke-Sqlcmd -Query $SQLQuery -ServerInstance Win7 -SuppressProviderContextWarning
foreach ($row in $QueryResults)
{
$row.Item(0)
}
Can you please help on how to find number of columns returned from above query.
My question would be... WHY is it necessary to do this in PowerShell instead of T-SQL?? :blink:
--Jeff Moden
Change is inevitable... Change for the better is not.