Getting Per-Table Space Utilization With Powershell

Drew Furgiuele provides us a script and a homework assignment:

Of course, PowerShell excels at this. By using the SQL Server module, it’s really easy to:

  • Connect to an instance and collect every user database, and
  • From each database, collect every table, and
  • For each table, collect row counts and space used, and
  • If there are any indexes, group them, and sum their usage and report that as well

Here’s the script. Note that I have the server name hard-coded in there as localhost (more on that in a coming paragraph). Go ahead and take a look before we break it down.

Click through for the script, and homework is due next Tuesday on his desk.

Related Posts

Tooling For SQL Server Automation With Powershell

Max Trinidad shares some tools you can use to automate SQL Server processes with Powershell: For script automation we could install either or both version of PowerShell Core: (As of February 19th, 2019)PowerShell Core GA version 6.1.3PowerShell Core Preview 6.2.0 Preview 4 Here are some important PowerShell Modules to use for SQL Server management scripting:*SQLServer – […]

Read More

Installing R From Powershell

Tomaz Kastrun shows us how to install R and RStudio via Powershell: For the brevity of this post, I will only download couple of R packages from CRAN repository, but this list is indefinite.There are ways many ways to retrieve the CRAN packages for particular R version using powershell. I will just demonstrate this by […]

Read More

Categories

May 2018
MTWTFSS
« Apr Jun »
 123456
78910111213
14151617181920
21222324252627
28293031