Link to home
Start Free TrialLog in
Avatar of Sharath S
Sharath SFlag for United States of America

asked on

Retrieving data using select SQL statement in Powershell

This URL stackoverflow.com/questions/1758779/retrieving-data-using-select-sql-statement-in-powershell helped in retrieving data from SQL query into a variable.
I would like to enhance this to retrieve multiple values.

$SqlCmd.CommandText = "select column1,column2 from table1"
$column1 = $SqlCmd.ExecuteScalar()

How can I assign column2 value into a variable.

Thanks
Sharath
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sharath S

ASKER

will get back on this
Thanks for pointing to use Executereader. Somehow, I am getting issues with this. I used a different approach to get the work done. Thanks.