Tag: Database Maintenance
-
Kill All User Sessions on a Database in SQL Server
When you need to drop, restore, or change database settings, active user sessions often get in the way. SQL Server will block these operations until all connections are cleared. In busy environments, waiting is rarely practical. This post shows a safe, deliberate, and review-first way to identify and kill all user sessions connected to a…
-
Script: Identify Missing Indexes
This script returns the highest-impact missing index recommendations based on cumulative workload statistics. It helps identify tables where SQL Server believes additional indexes could significantly improve query performance. This is useful during performance tuning, workload reviews, and when investigating high read activity or inefficient query plans. The Script Example Output The result set shows the…
-
Script: Check Index Fragmentation Across All Databases
This script checks index fragmentation levels across all online databases on the instance. It helps identify heavily fragmented indexes that may require maintenance. This is useful when reviewing index health, validating maintenance jobs, or troubleshooting performance issues related to inefficient index access. The Script Example Output The result set shows indexes across all user databases,…
-
Deleting Rows in Batches in SQL Server
Deleting large volumes of data from a SQL Server table looks simple, but it can cause real problems if done carelessly. A single large DELETE can: When you’re cleaning up historical data or running routine maintenance, deleting rows in batches is usually the safest and most predictable approach. This post shows a simple, production-safe pattern…
-
Get Database Sizes and Free Space in SQL Server
Keeping track of database file sizes and available free space is a basic but essential part of SQL Server administration. If you don’t know how large your data and log files are, or how much free space they contain, capacity planning becomes guesswork. Problems tend to surface late, usually during growth events, backups, or unexpected…
-
How to Check Transaction Log Space Usage in SQL Server
Monitoring transaction log space usage is a fundamental DBA task. If a log file runs out of space, transactions can fail, applications can stop, and in the worst cases databases can be taken offline. This post shows two practical ways to check log space usage in SQL Server, starting with a built-in command and then…
-
Applying Data Retention Safely in SQL Server
Data retention in SQL Server usually means deleting old data in a controlled and repeatable way. That might be driven by compliance requirements, table growth that’s starting to hurt performance, SQL Server Express size limits, or simply keeping log and audit tables under control. Whether this is a one-off cleanup or a permanent maintenance task,…
Blog Categories
Latest Posts
- Troubleshooting Database Mirroring Issues in SQL Server
- Get Current Date & Time in SQL Server
- Creating SQL Logins on an Availability Group (AG) Environment
- Grant VIEW SERVER STATE in SQL Server
- How to Get the SQL Server IP Address
- SQL Server Error Severities Explained
Blog Tags
Always On Availability Groups (4) Database Backups & Recovery (10) Database Maintenance (7) DBA Tools (29) Performance Troubleshooting (9) PowerShell (4) Query Behaviour (4) Schema Changes (1) SQL Agent (1) SQL Interview Questions (1) SQL Scripts (25) SQL Server Administration (9) SQL Server Configuration (7) SQL Server Errors (5) SQL Server High Availability (4) SQL Server Internals (4) SQL Server Management Studio (SSMS) (7) SQL Server Monitoring (10) SQL Server Networking (9) SQL Server Replication (1) SQL Server Security (8) SQL Server Versions (2) Storage and Capacity (14) T-SQL (9) Transaction Logs (8) Troubleshooting (14) Windows Server (4)