Get-sqmDatabaseCollationReport
SQL ConfigurationsqmSQLTool v1.9.116+ · Get🔓 VIEW ANY DEFINITION
char/varchar/nvarchar columns and tempdb objects (temp tables, table variables), or objects in another database with a different collation, can fail with Cannot resolve collation conflict unless every query adds an explicit COLLATE clause. Results are written as TXT and HTML report into -OutputPath, and the flat array of per-database result objects is still returned for further filtering.Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Optional | $env:COMPUTERNAME | Target SQL Server instance. |
| -SqlCredential | PSCredential | Optional | , | SQL or Windows credential. Without it: Windows authentication. |
| -Database | string[] | Optional | all user databases | Restrict the check to these database names. |
| -IncludeSystem | switch | Switch | $false | Include system databases in the check. |
| -OutputPath | string | Optional | Get-sqmDefaultOutputPath\CollationReports | Output directory for the TXT/HTML report files. |
| -NoOpen | switch | Switch | $false | Do not automatically open the generated report. |
| -NoReport | switch | Switch | $false | Skip writing the TXT/HTML files entirely - only the object array is returned. |
| -EnableException | switch | Switch | $false | Throw exceptions immediately instead of returning as errors. |
Execution Flow
Examples
Check all user databases on one instance
Get-sqmDatabaseCollationReport -SqlInstance "SQL01"
Include system databases and write to a custom folder
Get-sqmDatabaseCollationReport -SqlInstance "SQL01" -IncludeSystem -OutputPath "D:\Reports"
Only the mismatches, no report files
Get-sqmDatabaseCollationReport -SqlInstance "SQL01" -NoReport | Where-Object Status -eq 'Warning'
Sweep a list of instances
"SQL01","SQL02","SQL03" | ForEach-Object { Get-sqmDatabaseCollationReport -SqlInstance $_ -NoOpen }