Skip to content

Commit 241b94a

Browse files
Uwe Jankeclaude
andcommitted
v1.8.10.0: Show-sqmBackupExcludeForm — Job-Details via OBJECT_DEFINITION aus Proc-Body lesen
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 33a57e9 commit 241b94a

3 files changed

Lines changed: 40 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# sqmSQLTool — Changelog
22

3+
## [1.8.10.0] — 2026-07-02
4+
5+
### Bugfix
6+
7+
**`Show-sqmBackupExcludeForm`** — Job-Details im Info-Panel wieder korrekt
8+
- `Load-JobInfo` parste `@Databases`, `@Directory` etc. bisher aus dem Step-Command.
9+
Nach Umstellung auf Prozedur-Architektur (v1.8.7) enthaelt der Step nur noch
10+
`EXEC master.dbo.[sqm_Run_...]` — die Parameter stecken im Prozedurkoerper.
11+
- Fix: Proc-Name per Regex aus Step-Command extrahieren, dann
12+
`OBJECT_DEFINITION()` abfragen und daraus parsen. Fallback auf Step-Command
13+
fuer aeltere Jobs ohne Prozedur.
14+
- `@Databases` im ExcludeTable-Modus wird aus dem `DECLARE`-Statement gelesen
15+
(statt aus `@Databases = @Databases` im EXECUTE-Aufruf).
16+
317
## [1.8.9.0] — 2026-07-01
418

519
### Bugfix

Public/Show-sqmBackupExcludeForm.ps1

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,14 @@
438438
DIFF = if ($cfg['OlaJobNameDiff']) { $cfg['OlaJobNameDiff'] } else { 'OlaHH-UserDatabases-DIFF' }
439439
}
440440

441-
# Liest einen benannten Ola-Parameter aus dem Step-Command (static + dynamic T-SQL)
441+
# Liest einen benannten Ola-Parameter aus T-SQL (Step-Command oder Proc-Body)
442442
$parseParam = {
443-
param ([string]$cmd, [string]$p)
444-
if ($cmd -match "(?i)@$p\s*=\s*(?:N?'{1,2})([^']+)") { $Matches[1] } else { '' }
443+
param ([string]$sql, [string]$p)
444+
# Databases: auch DECLARE-Variante abfangen (UseExcludeTable-Architektur)
445+
if ($p -eq 'Databases' -and $sql -match "(?i)DECLARE\s+@Databases\s+\w+(?:\([^)]+\))?\s*=\s*N?'([^']+)'") {
446+
return $Matches[1]
447+
}
448+
if ($sql -match "(?i)@$p\s*=\s*(?:N?'{1,2})([^']+)") { $Matches[1] } else { '' }
445449
}
446450

447451
$lines = [System.Collections.Generic.List[string]]::new()
@@ -491,18 +495,28 @@
491495
}
492496
else { $schedStr = 'kein Schedule' }
493497

494-
# Step-Command
498+
# Step-Command lesen
495499
$cmd = ''
496500
$step = $job.JobSteps | Where-Object { $_.ID -eq 1 }
497501
if ($step) { $cmd = $step.Command }
498502

499-
$db = & $parseParam $cmd 'Databases'
500-
$dir = & $parseParam $cmd 'Directory'
501-
$cleanup = if ($cmd -match '(?i)@CleanupTime\s*=\s*(\d+)') { $Matches[1] } else { '' }
502-
$compress = & $parseParam $cmd 'Compress'
503-
$verify = & $parseParam $cmd 'Verify'
504-
$checksum = & $parseParam $cmd 'CheckSum'
505-
$hasExclude = $cmd -match 'sqm_BackupExclude'
503+
# Neue Architektur: Step ruft Prozedur — Proc-Body fuer Parameter-Parse laden
504+
$sqlToparse = $cmd
505+
if ($cmd -match '(?i)EXEC\s+master\.dbo\.\[([^\]]+)\]')
506+
{
507+
$procDef = Invoke-DbaQuery @script:connParams -Database master `
508+
-Query "SELECT OBJECT_DEFINITION(OBJECT_ID(N'[$($Matches[1])]', N'P')) AS Def" `
509+
-ErrorAction SilentlyContinue
510+
if ($procDef -and $procDef.Def) { $sqlToparse = $procDef.Def }
511+
}
512+
513+
$db = & $parseParam $sqlToparse 'Databases'
514+
$dir = & $parseParam $sqlToparse 'Directory'
515+
$cleanup = if ($sqlToparse -match '(?i)@CleanupTime\s*=\s*(\d+)') { $Matches[1] } else { '' }
516+
$compress = & $parseParam $sqlToparse 'Compress'
517+
$verify = & $parseParam $sqlToparse 'Verify'
518+
$checksum = & $parseParam $sqlToparse 'CheckSum'
519+
$hasExclude = $sqlToparse -match 'sqm_BackupExclude'
506520

507521
$lines.Add(" [$type] $jobName | Schedule: $schedStr")
508522
$lines.Add(" @Databases=$db @Directory=$dir @CleanupTime=${cleanup}h")

sqmSQLTool.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
RootModule = 'sqmSQLTool.psm1'
1818

1919
# Version number of this module.
20-
ModuleVersion = '1.8.9.0'
20+
ModuleVersion = '1.8.10.0'
2121

2222
# ID used to uniquely identify this module
2323
GUID = 'c4b10ba2-aee2-4d8d-ad86-a6e97c346ba6'

0 commit comments

Comments
 (0)