You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sp_ineachdb: add Azure SQL DB support as sp_MSforeachdb drop-in
Detect EngineEdition 5 and branch the two constructs Azure forbids:
- Skip the 3-part `[dbname].sys.sp_executesql` call; run `@cmd` in the
current DB via `EXEC sys.sp_executesql` instead.
- Seed `#ineachdb` with only the current database; downstream filter
DELETEs still apply.
Also rewrite incoming `@command` on Azure so sp_MSforeachdb-style inputs
work unchanged: strip `USE [?]`/`USE ?` variants and collapse
`[?].schema.object` / `?.schema.object` to 2-part names.
Box SQL, Managed Instance (EngineEdition 8), and other editions keep the
existing code path byte-for-byte.
FixesBrentOzarULTD#3943
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: sp_ineachdb.sql
+42-4Lines changed: 42 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,27 @@ BEGIN
105
105
@cr char(2) =CHAR(13) +CHAR(10),
106
106
@SQLVersion AS tinyint = (@@microsoftversion / 0x1000000) & 0xff, -- Stores the SQL Server Version Number(8(2000),9(2005),10(2008 & 2008R2),11(2012),12(2014),13(2016),14(2017),15(2019)
107
107
@ServerName AS sysname =CONVERT(sysname, SERVERPROPERTY('ServerName')), -- Stores the SQL Server Instance name.
0 commit comments