Skip to content

Commit ed578e4

Browse files
authored
Merge pull request BrentOzarULTD#3950 from BrentOzarULTD/claude/blitz-ineachdb
sp_Blitz: replace sp_MSforeachdb calls with sp_ineachdb
2 parents 0f65c4f + b82a318 commit ed578e4

3 files changed

Lines changed: 62 additions & 56 deletions

File tree

Documentation/Development/Build Installation Scripts.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,17 @@ if (Test-Path $BlitzFirstPath) {
151151
Write-Host " Built: Install-Azure.sql"
152152

153153
# ── Install-All-Scripts.sql ──────────────────────────────────────────────────
154-
# All sp_*.sql except sp_BlitzInMemoryOLTP.sql and sp_BlitzFirst.sql
155-
$allContent = Get-ChildItem -Path $RepoRoot -Filter "sp_*.sql" |
156-
Where-Object { $_.Name -notlike "*BlitzInMemoryOLTP*" -and $_.Name -notlike "*BlitzFirst*" } |
154+
# All sp_*.sql except sp_BlitzInMemoryOLTP.sql and sp_BlitzFirst.sql.
155+
# sp_ineachdb.sql must come first because sp_Blitz (and others) call it at
156+
# runtime — putting it ahead of sp_Blitz means the dependency exists by the
157+
# time later procs execute per-database checks.
158+
$IneachdbPath = Join-Path $RepoRoot "sp_ineachdb.sql"
159+
$allContent = @()
160+
if (Test-Path $IneachdbPath) {
161+
$allContent += Get-Content -Path $IneachdbPath -Raw -Encoding UTF8
162+
}
163+
$allContent += Get-ChildItem -Path $RepoRoot -Filter "sp_*.sql" |
164+
Where-Object { $_.Name -notlike "*BlitzInMemoryOLTP*" -and $_.Name -notlike "*BlitzFirst*" -and $_.Name -ne "sp_ineachdb.sql" } |
157165
ForEach-Object { Get-Content $_.FullName -Raw -Encoding UTF8 }
158166

159167
# Append SqlServerVersions.sql

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ When you have a question about what the scripts found, first make sure you read
7676
## sp_Blitz: Overall Health Check
7777
Run sp_Blitz daily or weekly for an overall health check. Just run it from SQL Server Management Studio, and you'll get a prioritized list of issues on your server right now.
7878

79+
**Note:** sp_Blitz requires `sp_ineachdb` (also shipped in this repo) to be installed in the same database. `Install-All-Scripts.sql` installs both automatically, with `sp_ineachdb` placed first. If you're installing scripts individually, install `sp_ineachdb.sql` before `sp_Blitz.sql`, or sp_Blitz will fail at runtime on its per-database checks. See the [sp_ineachdb section](#sp_ineachdb-run-a-command-in-each-database) below for details.
80+
7981
Output columns include:
8082

8183
* Priority - 1 is the most urgent, stuff that could get you fired. The warnings get progressively less urgent.

0 commit comments

Comments
 (0)