Lesson 12
Monitor SQL Server Databases Conclusion
This module discussed how to monitor SQL Server databases using SQL and SSMS.
Now you should be able to:
Here's a task-by-task breakdown showing how you can accomplish each using SQL Server Management Studio (SSMS) in SQL Server 2022, with modern best practices and notes on legacy commands like `sqlmaint.exe`.
✅ 1. Monitor the Size of a Database
How to do it in SSMS (2022):
- GUI Method:
- Right-click the database →
Reports
→ Standard Reports
→ Disk Usage
.
- You can also use
Disk Usage by Top Tables
.
- T-SQL Method:
- Advanced (per file):
✅ 2. Use `DBCC` to Monitor Databases
How to do it in SSMS (2022):
* Use the Query Editor to run DBCC commands such as:
DBCC SQLPERF(LOGSPACE); -- Transaction log size and usage
DBCC MEMORYSTATUS; -- Memory usage details
Note: Many `DBCC` monitoring commands have been replaced with DMVs like `sys.dm_os_memory_clerks`.
✅ 3. Monitor the Consistency of Individual Tables
How to do it in SSMS (2022):
✅ 4. Perform Miscellaneous Monitoring with `DBCC`
Common DBCC commands to run via SSMS:
Command |
Purpose |
DBCC SHOWCONTIG |
❌ Deprecated — use sys.dm_db_index_physical_stats |
DBCC INPUTBUFFER(spid) |
View last statement for a session |
DBCC OPENTRAN |
View oldest open transaction |
DBCC SQLPERF |
View log space usage |
🔍 *Prefer DMVs for modern monitoring.*
✅ 5. Monitor the Transaction Log
T-SQL in SSMS Query Window:
SELECT
DB_NAME(database_id) AS DatabaseName,
total_log_size_in_bytes / 1024 / 1024 AS TotalLogSizeMB,
used_log_space_in_bytes / 1024 / 1024 AS UsedLogSpaceMB,
used_log_space_in_percent
FROM sys.dm_db_log_space_usage;
Or:
DBCC SQLPERF(LOGSPACE);
✅ 6. Maintain Statistics
How to update statistics in SSMS:
✅ 7. View Statistics Information
Run in Query Editor:
DBCC SHOW_STATISTICS ('dbo.YourTableName', 'IndexOrStatName');
Or query metadata:
SELECT * FROM sys.stats WHERE object_id = OBJECT_ID('dbo.YourTableName');
⚠️ 8. Run `sqlmaint.exe`
❌ Deprecated in SQL Server 2005+
Replaced by Maintenance Plans and SQL Server Agent Jobs.
Use this instead:
- In SSMS: Management → Maintenance Plans → New Maintenance Plan
- Automates tasks like:
- Backup
- Reorganize/Rebuild Indexes
- Check DB Integrity
- Update Statistics
✅ 9. Use the Database Maintenance Plan Wizard
Steps in SSMS:
- Expand Management → Right-click Maintenance Plans → Choose Maintenance Plan Wizard.
- Choose tasks like:
- Backup Database
- Rebuild Index
- Update Statistics
- Check Database Integrity
- Cleanup History
- Assign to SQL Server Agent Schedule.
🧠 Summary
Task |
Modern Method in SSMS |
Monitor DB size |
Reports → Disk Usage or sp_spaceused |
Use DBCC |
Run via Query Editor (some commands deprecated) |
Table consistency |
DBCC CHECKTABLE |
Misc DBCC monitoring |
DBCC SQLPERF , DBCC OPENTRAN , DBCC INPUTBUFFER , etc. |
Monitor transaction log |
sys.dm_db_log_space_usage or DBCC SQLPERF(LOGSPACE) |
Maintain statistics |
UPDATE STATISTICS or sp_updatestats |
View statistics |
DBCC SHOW_STATISTICS or sys.stats |
Run sqlmaint.exe |
❌ Deprecated → use Maintenance Plans in SSMS |
Database Maintenance Plan Wizard |
Found under Management in SSMS GUI |
Glossary terms
The following terms were introduced to you in this module:
- Extent: SQL Server allocation unit. An extent is 8 data pages.
- Fragmentation: A condition that occurs when data is not stored consecutively.
- Leaf page: The lowest level of an index.
- Single user mode: A database that is configured to allow only one user to access it.
- Statistics: Track the data distribution.
The next module will cover how to use SQL Server Profiler to monitor SQL Server.
Develop Database Maintenance Plan - Exercise
Before you continue, click the Exercise link below to check your understanding of monitoring and maintaining databases.
Develop Database Maintenance Plan - Exercise

