O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving an Entry

On occasion, you might need to get a particular entry from a table. When the following code snippet is run, an array is automatically returned:

PS SQLSERVER:\SQL\D830\DEFAULT\databases\AdventureWorks2012>  Invoke-SqlCmd "Select * from Person.Person"

PowerShell provides a simple way to look at particular elements within an array. In the following example, entry 100 is returned and then entries 95 to 105:

PS SQLSERVER:\SQL\D830\DEFAULT\databases\AdventureWorks2012>  (Invoke-SqlCmd "Select * from Person.Person")[100]PS SQLSERVER:\SQL\D830\DEFAULT\databases\AdventureWorks2012>  (Invoke-SqlCmd "Select * from Person.Person")[95..105]

Note

The first element of an array ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required