|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 12:54 PM
Points: 41,
Visits: 120
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:46 PM
Points: 346,
Visits: 405
|
|
Where can I get this cmdlet Get-SqlDatabase? Am using PSv2.0, SQL08, WinXP.
"The term 'Get-SqlDatabase' is not recognized as the name of a cmdlet,"
There is an exception to every rule, except that one...
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: 2 days ago @ 9:36 AM
Points: 93,
Visits: 545
|
|
The hard way.... sheesh :)
Pass in an SMO sql object and here you go! (doing the log files is that easy as well)
Function Get-DatabaseFilesBySpaceAvailable ([Microsoft.SqlServer.Management.Smo.Server] $SmoSqlServer , [decimal] $sizeThreshold=0.85) { $sqlServer.Databases | Where-Object{$_.Status -eq "Normal"} ` | Select-Object FileGroups -ExpandProperty FileGroups ` | Select-Object Files -ExpandProperty Files ` | Where-Object {$_.MaxSize -gt -1} ` | Where-Object {$_.Size -gt ($_.MaxSize * $sizeThreshold)} ` | Select Name,UsedSpace,Size,MaxSize }
Cheers http://twitter.com/widba http://widba.blogspot.com/
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 9:25 AM
Points: 670,
Visits: 2,026
|
|
Hmmm... I usually just use SQL to find SQL data.
EXEC ('DBCC SQLPERF(logspace)'); - handles overall log information per database... but unless you have multiple Tlog files because you have critical drive space issues or for some other reason, that's not an issue. Runs on all DBs.
DBCC LOGINFO - shows VLFs in the Tlog (I particularly like watching Total Size/VLF; for very large Tlogs, this is more important). Runs on the current DB (so do dynamic SQL with a USE dbname; first).
DBCC SHOWFILESTATS - shows total and used extents for each data file. Runs on the current DB.
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: 2 days ago @ 9:36 AM
Points: 93,
Visits: 545
|
|
@Nadrek - using SQL is the normal way for most of us.
At some point, you are going to have too many servers to manage doing on a server by server basis.
Utilizing a script that reads your central inventory server or simply a text file, you can check over every database file on every server in your enterprise - no multiple deployments or huge server groups to manage in SSMS. (I run a whole battery of checks nightly on every server, as I find something else, i just add it to my monitoring scripts in one location, the next day I have new info)
To me, that is the benefit.
Cheers http://twitter.com/widba http://widba.blogspot.com/
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 9:25 AM
Points: 670,
Visits: 2,026
|
|
WI-DBA (5/11/2011) @Nadrek - using SQL is the normal way for most of us.
At some point, you are going to have too many servers to manage doing on a server by server basis.
Utilizing a script that reads your central inventory server or simply a text file, you can check over every database file on every server in your enterprise - no multiple deployments or huge server groups to manage in SSMS. (I run a whole battery of checks nightly on every server, as I find something else, i just add it to my monitoring scripts in one location, the next day I have new info)
To me, that is the benefit.
That's why the script INSERTS INTO a central monitoring server from each server I manage, based on SQL Server Agent Jobs; I just read from the central monitoring server.
The SQL Server Agent Jobs and SP's are distributed using SSMS's Multiple Instance capability, based on Registered Server groups.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 12:54 PM
Points: 41,
Visits: 120
|
|
Nadrek (5/11/2011)
WI-DBA (5/11/2011) @Nadrek - using SQL is the normal way for most of us.
At some point, you are going to have too many servers to manage doing on a server by server basis.
Utilizing a script that reads your central inventory server or simply a text file, you can check over every database file on every server in your enterprise - no multiple deployments or huge server groups to manage in SSMS. (I run a whole battery of checks nightly on every server, as I find something else, i just add it to my monitoring scripts in one location, the next day I have new info)
To me, that is the benefit.That's why the script INSERTS INTO a central monitoring server from each server I manage, based on SQL Server Agent Jobs; I just read from the central monitoring server. The SQL Server Agent Jobs and SP's are distributed using SSMS's Multiple Instance capability, based on Registered Server groups. Looks like you read my mind on the next article in the series
@SQLvariant I have a PowerShell script for you.
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: 2 days ago @ 9:36 AM
Points: 93,
Visits: 545
|
|
@Nadrek - Its a preference really, I don't like having lots of maintenance jobs on my servers, and when I come up with something new to check, the single deployment makes the whole process much quicker to deploy.
Cheers http://twitter.com/widba http://widba.blogspot.com/
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, May 12, 2011 4:24 PM
Points: 6,
Visits: 13
|
|
On the SQL server I only have PS1 and the hard way gives me error: Unexpected token 'in' in expression or statement. At D:\Temp\freeInDB.ps1:11 char:40 + $cmdStatement+=foreach ($DFileGroups in <<<< $db.FileGroups)
I just need to know how much unused space (GB) I have in 309GB database.
even a SQL script will do.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:46 PM
Points: 346,
Visits: 405
|
|
Ofer Gal (5/11/2011) On the SQL server I only have PS1 and the hard way gives me error: Unexpected token 'in' in expression or statement. At D:\Temp\freeInDB.ps1:11 char:40 + $cmdStatement+=foreach ($DFileGroups in <<<< $db.FileGroups)
I just need to know how much unused space (GB) I have in 309GB database.
even a SQL script will do.
DBCC SQLPERF(logspace)
There is an exception to every rule, except that one...
|
|
|
|