We help IT Professionals succeed at work.

Retrieving data using select SQL statement in Powershell

Sharath S
Sharath S asked
on
7,490 Views
Last Modified: 2013-12-16
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
Comment
Watch Question

Messaging and Directory Services
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Sharath SData Engineer
CERTIFIED EXPERT

Author

Commented:
will get back on this
Sharath SData Engineer
CERTIFIED EXPERT

Author

Commented:
Thanks for pointing to use Executereader. Somehow, I am getting issues with this. I used a different approach to get the work done. Thanks.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.