Skip to content

Latest commit

 

History

History
374 lines (284 loc) · 10.8 KB

File metadata and controls

374 lines (284 loc) · 10.8 KB

📥 Importing sp_Blitz Checks - Complete Guide

What Is This Feature?

The SQL Monitor UI now has a "Import sp_Blitz" button that automatically:

  1. Reads the sp_Blitz.sql file you provide
  2. Extracts all the check definitions (CheckID, Priority, FindingsGroup, Finding, URL)
  3. Converts them to our simplified check format
  4. Merges with your existing checks (keeping your custom settings)
  5. Saves to sql-checks.json

No manual editing required! 🎉

How to Use It

Step 1: Get sp_Blitz.sql

Download the latest sp_Blitz.sql from: https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit

Or use the file you already uploaded!

Step 2: Click the Import Button

  1. Open SqlMonitorUI
  2. Look for the "📥 Import sp_Blitz" button in the header
  3. Click it

Step 3: Select the File

  1. A file dialog will open
  2. Navigate to your sp_Blitz.sql file
  3. Select it and click Open

Step 4: Review the Summary

The app will show you:

Found 210 checks in sp_Blitz.sql

New checks to add: 198
Existing checks to update: 12

Total checks after import: 210

Note: Only ~30 checks with simplified queries will run.
Others will be placeholders until queries are implemented.

Continue with import?

Step 5: Confirm

Click Yes to import, or No to cancel.

Step 6: Done!

You'll see:

Successfully imported 210 checks from sp_Blitz!

Total checks: 210
Enabled by default: ~120

You can now run the checks or edit sql-checks.json to customize them.

What Gets Imported?

Complete Coverage

ALL 210+ CheckIDs from sp_Blitz.sql
Every check that Brent Ozar's team has created
Automatic extraction of CheckID, Priority, FindingsGroup, Finding, URL

Imported Information

CheckID - Original sp_Blitz check number (1-2301)
Finding Name - What the check looks for
Priority - Severity (1-250)
FindingsGroup - Category (Backup, Security, Performance, etc.)
URL - Link to more information

Auto-Generated

Simplified SQL Query - ~30 checks have working queries
Severity Mapping - Priority 1-50 = Critical, 51-100 = Warning, 101+ = Info
Enable/Disable - Enabled by default for Priority ≤ 100

What About Complex Checks?

The Reality: sp_Blitz has incredibly complex queries. Many:

  • Use dynamic SQL
  • Query every database
  • Check plan cache
  • Run DBCC commands
  • Have hundreds of lines of code

Our Approach:

  1. ~30 common checks get full working queries immediately
  2. ~180 complex checks get placeholder queries that return 0 (not implemented yet)
  3. You can edit sql-checks.json to add real queries later

Implemented Checks (Will Actually Run)

These ~30 checks have working simplified queries:

Backup (4 checks)

  • ✅ CheckID 1: Full Backup Recency
  • ✅ CheckID 2: Transaction Log Backup Recency
  • ✅ CheckID 3: Old Backups in MSDB
  • ✅ CheckID 93: Backing Up to Same Drive

Performance (10 checks)

  • ✅ CheckID 21: Auto Shrink Enabled
  • ✅ CheckID 50: Max Memory Not Configured
  • ✅ CheckID 51: Min Equals Max Memory
  • ✅ CheckID 90: Auto Close Enabled
  • ✅ CheckID 83: Auto Create Stats Disabled
  • ✅ CheckID 84: Auto Update Stats Disabled
  • ✅ CheckID 33: High Index Fragmentation
  • ✅ CheckID 34: Missing Index Recommendations
  • ✅ CheckID 59: Deprecated Features
  • ✅ CheckID 69: High VLF Count

TempDB (3 checks)

  • ✅ CheckID 40: TempDB Only Has 1 Data File
  • ✅ CheckID 183: TempDB Unevenly Sized Files
  • ✅ CheckID 170: TempDB Files Less Than CPU Count

Security (4 checks)

  • ✅ CheckID 71: Weak Password Policy
  • ✅ CheckID 72: Password Expiration Disabled
  • ✅ CheckID 73: SA Account Enabled
  • ✅ CheckID 119: TDE Without Key Backup

Configuration (9 checks)

  • ✅ CheckID 26: Autogrowth Disabled
  • ✅ CheckID 27: Percent Growth Settings
  • ✅ CheckID 61: System DBs on C Drive
  • ✅ CheckID 62: User DBs on C Drive
  • ✅ CheckID 94: Old Compatibility Level
  • ✅ CheckID 126: Priority Boost Enabled
  • ✅ CheckID 102: Unlimited File Growth
  • ✅ CheckID 28: Simple Recovery Model
  • ✅ CheckID 55: Express/Web Edition

Integrity (2 checks)

  • ✅ CheckID 89: Database Corruption Detected
  • ✅ CheckID 6: Page Verify Not CHECKSUM

Reliability (2 checks)

  • ✅ CheckID 57: SQL Agent Not Running
  • ✅ CheckID 67: Unusual Database Owner

Total: ~34 checks with working queries out of 210

The rest (~176 checks) are placeholders you can implement!

Merging Logic

What Happens to Existing Checks?

Scenario 1: Check Already Exists (same ID)

  • ✅ Updates Name, Description, SQL Query, Category, Severity
  • KEEPS your Enabled/Disabled setting (respects your choice!)
  • ✅ Updates Recommended Action and URL

Scenario 2: New Check (not in your list)

  • ✅ Adds it to sql-checks.json
  • ✅ Enabled by default if Priority ≤ 100
  • ✅ Disabled by default if Priority > 100 (info checks)

Scenario 3: Custom Check (you added manually)

  • ✅ Not touched! Your custom checks stay exactly as you made them

After Import - What Next?

Option 1: Run Checks Immediately

  1. Enter your SQL Server connection string
  2. Click "Run Checks"
  3. See results for all enabled checks

Option 2: Review and Customize

  1. Open sql-checks.json in a text editor
  2. Review the imported checks
  3. Disable checks you don't want
  4. Implement queries for placeholder checks
  5. Run checks

Option 3: Hybrid Approach

  1. Run checks to see what works
  2. Edit sql-checks.json to add queries for important placeholders
  3. Run again with more complete coverage

Sample sql-checks.json After Import

[
  {
    "id": "BLITZ_001",
    "name": "Backup Hasn't Happened Recently",
    "description": "Backup Hasn't Happened Recently (sp_Blitz CheckID 1, Priority 1)",
    "category": "Backup",
    "severity": "Critical",
    "sqlQuery": "SELECT CASE WHEN EXISTS (...) THEN 1 ELSE 0 END",
    "expectedValue": 0,
    "enabled": true,
    "recommendedAction": "Review finding: Backup Hasn't Happened Recently. More info: https://www.brentozar.com/go/backup"
  },
  {
    "id": "BLITZ_050",
    "name": "Max Memory is 2147483647 MB",
    "description": "Max Memory is 2147483647 MB (sp_Blitz CheckID 50, Priority 50)",
    "category": "Performance",
    "severity": "Critical",
    "sqlQuery": "SELECT CASE WHEN EXISTS (...) THEN 1 ELSE 0 END",
    "expectedValue": 0,
    "enabled": true,
    "recommendedAction": "Review finding: Max Memory is 2147483647 MB. More info: https://www.brentozar.com/go/max"
  },
  {
    "id": "BLITZ_200",
    "name": "Rare Wait Detected",
    "description": "Rare Wait Detected (sp_Blitz CheckID 200, Priority 200)",
    "category": "Performance",
    "severity": "Info",
    "sqlQuery": "SELECT 0 AS Result -- sp_Blitz CheckID 200: Rare Wait Detected (not yet implemented)",
    "expectedValue": 0,
    "enabled": false,
    "recommendedAction": "Review finding: Rare Wait Detected. More info: https://www.brentozar.com/go/waits"
  }
]

Implementing Placeholder Checks

Want to add real queries to the placeholders?

  1. Find the check in sql-checks.json
  2. Look up the original SQL in sp_Blitz.sql (search for the CheckID)
  3. Simplify it to return 0 or 1
  4. Replace the placeholder query
  5. Save and run!

Example: Implementing CheckID 55 (Unusual Edition)

Original in sp_Blitz.sql (line ~2500):

IF CAST(SERVERPROPERTY('Edition') AS VARCHAR(100)) LIKE '%Express%'
   OR CAST(SERVERPROPERTY('Edition') AS VARCHAR(100)) LIKE '%Web%'
   INSERT INTO #BlitzResults ...

Your Implementation:

{
  "id": "BLITZ_055",
  "name": "Unusual SQL Server Edition",
  "sqlQuery": "SELECT CASE WHEN CAST(SERVERPROPERTY('Edition') AS VARCHAR(100)) LIKE '%Express%' OR CAST(SERVERPROPERTY('Edition') AS VARCHAR(100)) LIKE '%Web%' THEN 1 ELSE 0 END",
  "expectedValue": 0,
  "enabled": true
}

Easy!

Re-Importing (Updates)

What Happens If You Import Again?

sp_Blitz gets updated regularly. When you re-import:

  1. ✅ New checks from updated sp_Blitz are added
  2. ✅ Existing checks are updated with new info
  3. Your enabled/disabled settings are preserved
  4. ✅ Your custom checks are untouched

Safe to re-import anytime!

Priority Mapping

sp_Blitz Priority Our Severity Enabled by Default?
1-50 Critical ✅ Yes
51-100 Warning ✅ Yes
101-250 Info ❌ No

Troubleshooting

"No checks found in the sp_Blitz.sql file"

Problem: Parser couldn't find check patterns
Solution: Make sure you're using a real sp_Blitz.sql file from Brent Ozar's GitHub

"Error importing sp_Blitz: System.IO.FileNotFoundException"

Problem: File path is invalid
Solution: Make sure the file exists and you have permission to read it

"Imported successfully but checks return 'not yet implemented'"

This is normal! Only ~15-20 checks have working queries. The rest are placeholders.

Solution: Either:

  • Live with the checks that work (they're the most important ones anyway)
  • Implement more queries yourself in sql-checks.json
  • Wait for future updates with more implemented queries

"All my custom checks disappeared!"

This shouldn't happen - the merge logic preserves everything.

Solution:

  1. Check if you have a backup of sql-checks.json
  2. Restore from backup
  3. Report the bug!

Tips for Success

🎯 Start Small

  1. Import sp_Blitz
  2. Run checks to see what works
  3. Disable noisy checks
  4. Implement a few important placeholders
  5. Run again

📝 Keep a Backup

Before importing:

copy sql-checks.json sql-checks-backup.json

🔄 Update Regularly

When Brent releases a new sp_Blitz:

  1. Download latest sp_Blitz.sql
  2. Click "Import sp_Blitz"
  3. Confirm the import
  4. Your settings are preserved!

🎨 Customize After Import

The imported checks are a starting point:

  • Adjust severity levels
  • Change categories
  • Modify queries
  • Disable irrelevant checks
  • Add your own checks

Advanced: Adding More Implemented Checks

Want to contribute? Here's how to add more working queries to the parser:

Edit SpBlitzParser.cs, find the GenerateSimplifiedQuery method, and add your CheckID:

private string GenerateSimplifiedQuery(BlitzCheck blitz)
{
    var simplifiedQueries = new Dictionary<int, string>
    {
        // Add your new check here!
        [123] = "SELECT CASE WHEN ... THEN 1 ELSE 0 END",
    };
    ...
}

Then rebuild and you'll have more working checks!

Summary

One Click - Import all sp_Blitz checks automatically
Smart Merging - Preserves your settings
Ready to Use - 15-20 checks work immediately
Extensible - Add more queries as needed
Safe Updates - Re-import anytime without losing settings

Try it now! Click that "📥 Import sp_Blitz" button! 🎉