· Uwe Janke
Commands / Get-sqmSupportedCollations

Get-sqmSupportedCollations

SQL ConfigurationsqmSQLTool v1.9.117+ · Get🔓 CONNECT (public)
Queries sys.fn_helpcollations() on the target instance and returns the collation names, optionally filtered by a wildcard pattern. The set of valid collations depends on the SQL Server version and edition, so this is deliberately asked of the instance rather than hard-coded: a static list would go stale, offer collations the target does not actually support, and miss newer ones. Mainly used to discover or validate a value for -NewCollation of Invoke-sqmCollationChange, and to feed the collation picker in Show-sqmToolGui.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestringOptional$env:COMPUTERNAMETarget SQL Server instance.
-SqlCredentialPSCredentialOptional, SQL or Windows credential. Without it: Windows authentication.
-FilterstringOptional*Wildcard pattern to restrict the result, e.g. 'Latin1_General*' or '*_CI_AS'.
-EnableExceptionswitchSwitch$falseThrow exceptions immediately instead of returning as errors.

Execution Flow

START dbatools installed? NO throw: dbatools not found YES SELECT name FROM sys.fn_helpcollations() Asked of the instance live - the valid set depends on version and edition -Filter given? NO Return everything Thousands of them on a modern instance YES Apply the wildcard pattern PowerShell -like matching, e.g. 'German*' or '*_CI_AS' Return [PSCustomObject] per collation SqlInstance ยท CollationName DONE

Examples

All collations the instance supports
Get-sqmSupportedCollations -SqlInstance "SQL01"
Only the German collations
Get-sqmSupportedCollations -SqlInstance "SQL01" -Filter "German*"
Validate a target collation before a collation change
$target = "Latin1_General_CI_AS"
if (Get-sqmSupportedCollations -SqlInstance "SQL01" -Filter $target) {
    Invoke-sqmCollationChange -SqlInstance "SQL01" -Database "AdventureWorks" -NewCollation $target -WhatIf
}