Category: Maintenance
-
DBA Scripts: Enable or Disable All SQL Agent Jobs
Turning every SQL Agent job off is easy. Turning the right ones back on is where it goes wrong. Save the state first, disable with sp_update_job, restore from what you saved, and know why disabling does not stop a running job.
Written by
-
DBA Scripts: Generate Database Integrity and Housekeeping Jobs
A Readable Generator for Integrity Checks and msdb Housekeeping No DBCC CHECKDB has run in weeks, msdb keeps growing, or the error log is one enormous file: this generator writes the three SQL Agent jobs that cover all of it, as plain sp_add_job DDL you read before anything touches msdb. The jobs are DBA -…
Written by
-
DBA Scripts: Generate Backup Jobs
A Readable Generator for Full Backups, Log Backups, and Cleanup If you’re already running Ola Hallengren’s maintenance solution, this won’t replace it, but the approach here might still be useful: a small, readable T-SQL generator that builds a backup job framework as plain sp_add_job / sp_add_jobstep DDL you can review line by line before you…
Written by
-
DBA Scripts: Run a Full SQL Server Health Check
Is This SQL Server Okay? Collect, Review, Then Find the Root Cause Inherited a server, or sure something is wrong but not what? One command runs 45 read-only checks against the instance. A second turns the results into a ranked CRITICAL / WARNING / INFO list. An optional third hands the lot to an AI…
Written by
-
DBA Scripts: Get Job Schedules and Duration Trends
When Jobs Run, and Whether They’re Taking Longer to Do It SQL Agent Job Failure Summary tells you what broke. These two scripts answer two quieter but just as important questions: Get-JobScheduleSummary shows exactly when every enabled job is scheduled to run next, useful for spotting overlapping windows or confirming a schedule change actually took…
Written by
-
How to Shrink SQL Server Database Files in Chunks
A data file that’s grown far past what the database actually needs, after a one-off bulk load, an archive cleanup, a migration that left behind a much bigger footprint than the data now occupies, eventually needs to come back down. The problem is that a single DBCC SHRINKFILE targeting the final size all at once…
Written by
-
DBA Scripts: Get Index Fragmentation
Index fragmentation is one of those topics where the received wisdom, “rebuild your indexes every weekend”, causes almost as many problems as it solves. Rebuilding an index that doesn’t need it wastes a maintenance window, takes a schema lock on Standard Edition, and generates unnecessary transaction log. Not rebuilding an index that does need it…
Written by
-
DBA Scripts: Collect AG Health, Index Fragmentation, Query Store and Error Log Baselines
History for AG Health, Indexes, Query Store and the Error Log When something breaks, the first question is what it looked like before: was the AG secondary already behind last night, when did that query start burning CPU, how long has that login been failing. Most of what SQL Server shows you is point in…
Written by
-
DBA Scripts: Collect TempDB Space, VLF Count and Database Growth Baselines
History for TempDB Space, VLF Counts and Database Growth TempDB filled overnight, or a database grew and nobody knows when: questions only history can answer. The DMVs show how full TempDB is and how big each file is now, not what they looked like at 3am or last month. These scripts set up SQL Agent…
Written by
-
DBA Scripts: Collect Performance Baselines (Wait Stats, Perfmon, Storage I/O)
History for Wait Stats, Perfmon Counters and Storage I/O Something was slow between two and three this afternoon, and you want to know what the server was waiting on and whether the disks were struggling. sys.dm_os_wait_stats and sys.dm_io_virtual_file_stats count up from the last restart, and so do the per-second counters in sys.dm_os_performance_counters, so a single…
Written by
- Tune a Slow Query With Copilot in SSMS
- xp_readerrorlog: Read the SQL Server Error Log with T-SQL
- Cannot Drop Database Because It Is Currently in Use (Error 3702)
- Could Not Drop Login Because the User Is Currently Logged In (Error 15434)
- Set a Maximum Database File Size in SQL Server (MAXSIZE)
- SQL Server Activity Monitor in SSMS (and the Performance Dashboard)
- Backups & Recovery (18)
- DBA Scripts (154)
- High Availability (HA) (13)
- Installation & Configuration (60)
- Maintenance (25)
- Migration & Upgrades (14)
- Monitoring (10)
- Performance Tuning (38)
- Security (Encryption & Permissions) (25)
- Storage & Capacity (18)
- T-SQL Fundamentals (17)
- Troubleshooting (108)
- Wait Types (236)