Maximo 的个人资料Max - Put It Together照片日志列表更多 ![]() | 帮助 |
|
|
10月21日 Connect to a remote SQL Server using SQLPS.Displaying a list of tables with their rows count: 1. You need to have installed an instance of SQL Server 2008 (or 2008 R2) in order to use SQLPS. 2. To connect to another SQL Server remotely, you need to make sure the server(s) are properly registered in your SQL Management Studio (2008/2008-R2). Look in the *“Registered Servers” pane. *Hint: You should be able to query SQL Server 2000, and 2005. 3. To start using SQLPS, there’s three ways to open it:
4. Start SQLPS session: 5. Check your SQL Registered Servers: 6. Here’s a very useful one-liner cmdlet to get tables –rowcounts and generate some output:
The first line use the “CD” to change directory to the remote server tables folder. Then, use the “dir” to list all tables. If you need to find more information about that folder then use the “Get-Member” (or the alias “gm”) so you can see that properties and methods you have available at your finger tips. Example, use the following approach to save the results on a variable and then use “Get-member”:
Then, using the Cmdlet “Select” (short for “Select-Object”), you can work with the properties: “Name” and “RowCount” to be displayed in the PowerShell Console:
dir | Select name, rowcount … Results: Have fun with SQLPS!! 引用通告引用此项的网络日志
|
|
|