The GetServerDatabaseInfo
stored procedure delivers detailed insights into your SQL Server instance and its databases. This procedure consolidates critical information, including database status, server status, disk usage, backup details, job statuses, and various performance metrics. It is an essential tool for database administrators to effectively monitor and optimize their SQL Server environments.
- SQL Server 2012 or later
- Sufficient permissions to access system views and execute stored procedures
- Open SQL Server Management Studio (SSMS).
- Connect to the SQL Server instance where the stored procedure will be deployed.
- Open a new query window.
- Copy and paste the
GetServerDatabaseInfo
stored procedure script into the query window. - Execute the script to create the stored procedure.
-- Insert the GetServerDatabaseInfo stored procedure script here
To execute the stored procedure, use the following command:
EXEC GetServerDatabaseInfo;
This command will execute the procedure and provide comprehensive details about your SQL Server instance and databases.
- Database ID
- Database Name
- Creation Date
- Owner Name
- User Access Description
- State Description
- Compatibility Level
- Recovery Model Description
- Database Size (MB)
- Hostname
- SQL Server Version
- Edition
- Clustered Instance Status
- Single User Mode Status
- Logical Name
- Drive
- Free Space (GB)
- Total Space (GB)
- Occupied Space (GB)
- Database Name
- Backup Type
- Backup Start Date
- Backup Finish Date
- Username
- Backup Size (MB)
- Backup Taken By
- Server Name
- Category Name
- Job Name
- Owner ID
- Enabled Status
- Next Run Date
- Last Run Date
- Job Status
- Server Version
- List of Databases
- Database Sizes
- Total Server Memory (MB)
- Target Server Memory (MB)
- CPU Usage Percentage
- Long Running Queries
- Blocked Processes
- CPU and Memory Utilization
- I/O Statistics
- Wait Statistics
- Error Logs
- Index Fragmentation
- Query Store Information
- Blocking and Deadlocks
- Security and Permission Audits
- CPU and Memory Utilization: Details about CPU and memory usage.
- I/O Statistics: Insights into read and write operations and their latencies.
- Wait Statistics: Various wait types and their durations.
- Error Logs: Recent error logs from the SQL Server.
- Index Fragmentation: Fragmented indexes and their fragmentation percentages.
- Query Store Information: Details about the most resource-intensive queries.
- Blocking and Deadlocks: Blocking sessions and deadlocks.
- Security and Permission Audits: Permissions for various database principals.
- Ensure you have the necessary permissions to access system views and execute the stored procedure.
- Review error messages for specific issues related to permissions or missing objects if you encounter errors.
- For large databases or instances with many jobs, the procedure might take some time to execute. Consider running it during off-peak hours.
This documentation provides an overview of the GetServerDatabaseInfo
stored procedure, covering its installation, usage, and the details it outputs. It serves as a guide for database administrators to effectively monitor and optimize their SQL Server environments.