Collation check


Job details

Name: Collation check
Platform: Sqlserver
Category: Availability
Description: Checks if there is a collation conflict with temp tables and table variables.
Long description: You may get a collation conflict when the collation of your user database does not match the collation of tempdb database. Whenever you join with the temp table (without specifying the collation for string columns) they will inherit the default collation for tempdb database causing collation conflict.
Version: 1.4
Default schedule: 30 7 7 *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2000′ & hasengine=‘YES’ & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
ignore databases model List of databases (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.
ignore OFFLINE databases YES If set to “YES“ databases with status OFFLINE will be ignored.
return status 0 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when collation conflict.
ignore collations List of collations (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.

Job Summary

SELECT name, DATABASEPROPERTYEX(name, 'Collation') AS Collation, DATABASEPROPERTYEX(name,'Status') AS Status
FROM master.dbo.sysdatabases
WHERE DATABASEPROPERTYEX(name, 'Collation') != DATABASEPROPERTYEX('tempdb', 'Collation')

Job Implementation Details

Dependencies

Job Configuration Parameters

These are key adjustable parameters that influence the job’s execution but have been instructed not to be explicitly described.

Output Visualization

Database Issues Number of Occurrences
Application databases Multiplicity of collations calculated per group
Specific databases (‘master’, ‘msdb’, ‘model’, ‘tempdb’) Specific collation details 1

Versioning and Updates

In summary, this job is critical for maintaining the operational compatibility and stability of SQL queries involving user databases and tempdb by monitoring and alerting on collation mismatches.