Category: Maintenance

  • DBA Scripts: Generate Database Integrity and Housekeeping Jobs

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Maintenance Job Framework A Readable Generator for Integrity Checks and msdb Housekeeping 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…

  • DBA Scripts: Generate Backup Jobs

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Maintenance Job Framework 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…

  • DBA Scripts: Run a Full SQL Server Health Check

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Collectors & Baselines Most of the 180+ scripts on this site answer one specific question, run when you already know what you’re looking for. This post is different. It’s the workflow for the moment you don’t know what to…

  • DBA Scripts: Get Job Schedules and Duration Trends

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › SQL Agent & Jobs 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…

  • How to Shrink SQL Server Database Files in Chunks

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Storage & Capacity 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.…

  • DBA Scripts: Get Index Fragmentation

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Index Maintenance 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…

  • DBA Scripts: Collect Health and Configuration Baselines

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Collectors & Baselines Four Collectors, Four Different Rhythms AG health every few minutes if you’re running Availability Groups, index fragmentation weekly, Query Store’s top queries every 30 minutes, error log entries every 10. Each script below is a generator:…

  • DBA Scripts: Collect Capacity and Temp DB Baselines

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Collectors & Baselines Three Collectors for Capacity and TempDB DatabaseGrowth and VlfCount are system-versioned temporal tables, always current, no manual history-cleanup needed. The TempDB collector snapshots both file-level space and the top 10 session consumers in one pass. Each…

  • DBA Scripts: Collect Performance Baselines (Wait Stats, Perfmon, Storage I/O)

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Collectors & Baselines Three Cumulative Counters, Three Matching Delta Scripts sys.dm_os_wait_stats, sys.dm_os_performance_counters, and sys.dm_io_virtual_file_stats are all cumulative since the instance last started, a raw snapshot of any of them tells you almost nothing on its own. Three collector generators…

  • DBA Scripts: Collect Blocking and Deadlock Events

    ,

    🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.In: Maintenance & Automation › Collectors & Baselines Standing Watch for Blocking and Deadlocks, Not Just Checking When Asked Get Blocking Sessions and Get Deadlock Summary answer “what’s happening right now.” These two generators answer a different question: “what happened while nobody was looking.”…