· Uwe Janke
Commands / Import-sqmDatabaseSettings

Import-sqmDatabaseSettings

SQL ConfigurationsqmSQLTool v1.9.88+ · Import🔓 ALTER on the target databases
Counterpart to Export-sqmDatabaseSettings. Reads the JSON snapshot at -InputPath and, for every database it contains that also exists on -SqlInstance, compares each captured Options setting (from Get-sqmDatabaseSettingsDefinition) against the live value and applies only the ones that actually differ, as one ALTER DATABASE ... SET statement per changed setting, so a partial failure never blocks the remaining settings (see -ContinueOnError). Two properties of the definitions are respected. Settings with AlterOption = $null (CollationName, ContainmentDesc, StateDesc, UserAccessDesc) are informational only and are never applied, regardless of any switch. Settings marked Exclusive (ReadOnly, ReadCommittedSnapshot, BrokerEnabled) need WITH ROLLBACK IMMEDIATE and can terminate active connections, so they are applied only with -IncludeExclusiveOptions; without it a differing exclusive setting is reported as Skipped, so it stays visible instead of silently vanishing.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestringRequired, Target instance the snapshot is applied to.
-SqlCredentialPSCredentialOptional, SQL or Windows credential. Without it: Windows authentication.
-InputPathstringRequired, Path to the JSON file produced by Export-sqmDatabaseSettings. Validated to exist.
-Databasestring[]Optionalevery database in the snapshotRestrict the import to these database names from the snapshot (wildcards allowed).
-ExcludeDatabasestring[]Optional, Additional database names to exclude (wildcards allowed).
-IncludeExclusiveOptionsswitchSwitch$falseAlso apply ReadOnly / ReadCommittedSnapshot / BrokerEnabled. These use WITH ROLLBACK IMMEDIATE and terminate other active connections.
-ContinueOnErrorswitchSwitch$falseContinue with the next setting/database if one fails instead of aborting the whole run.
-EnableExceptionswitchSwitch$falseThrow exceptions immediately. Overrides -ContinueOnError.
-WhatIf / -ConfirmswitchSwitchConfirmImpact = MediumShow or confirm what would be applied per database before anything changes.

Execution Flow

START dbatools installed? NO throw: dbatools not found YES Read the JSON snapshot at -InputPath Produced by Export-sqmDatabaseSettings · -Database / -ExcludeDatabase narrow the set Database from the snapshot exists on the target? NO Skip the database Reported as Skipped, never created here YES Compare each captured setting to the live value Get-sqmDatabaseSettingsDefinition drives what is comparable AlterOption = $null (Collation, Containment, State, UserAccess) is informational only Setting differs? NO Nothing to do No ALTER DATABASE is issued YES Exclusive setting without -IncludeExclusiveOptions? YES Reported as Skipped ReadOnly, ReadCommittedSnapshot, BrokerEnabled: WITH ROLLBACK IMMEDIATE NO ALTER DATABASE ... SET <option> One statement per changed setting - a partial failure never blocks the rest -ContinueOnError decides whether a failure aborts the run Return [PSCustomObject] per setting SqlInstance · Database · Setting · CurrentValue · DesiredValue Status: Success / Skipped / Failed / WhatIf DONE

Examples

Apply every differing, non-exclusive Options setting from a snapshot
Import-sqmDatabaseSettings -SqlInstance 'SQL01' -InputPath 'C:\Backups\SQLSnapshots\DatabaseSettings_SQL01_20260810_120000.json'
Restore one database fully, including the exclusive options
Import-sqmDatabaseSettings -SqlInstance 'SQL01' -InputPath '.\baseline.json' -Database 'Frontarena' -IncludeExclusiveOptions
Dry run before a maintenance window
Import-sqmDatabaseSettings -SqlInstance 'SQL01' -InputPath '.\baseline.json' -WhatIf
Capture a baseline first, restore it later
Export-sqmDatabaseSettings -SqlInstance 'SQL01' -OutputPath 'C:\Backups\SQLSnapshots'
# ... changes happen ...
Import-sqmDatabaseSettings -SqlInstance 'SQL01' -InputPath 'C:\Backups\SQLSnapshots\DatabaseSettings_SQL01_20260810_120000.json' -ContinueOnError