The initial problem is that yes, there are several places in sp_blitz that compare a string column: database name. The comparison is usually (I didn't check the entire proc) between the system catalog view, sys.databases
, and the temporary table, #SkipChecks
in a NOT IN
predicate:
FROM master.sys.databases d
...
WHERE ...
AND d.name NOT IN ( SELECT DISTINCT
DatabaseName
FROM #SkipChecks
...
Part 1
So, the immediate problem is that:
The collation of the name
column in sys.databases
is Latin1_General_BIN
, which correctly reflects your instance/server -level collation, but the collation of the DatabaseName
column in SkipChecks
is SQL_Latin1_General_CP1_CI_AS
due to this being a temporary table and by default, the collation of string columns is taken from the default collation of tempdb
, which on your system is SQL_Latin1_General_CP1_CI_AS
.
AND
The collation of the predicate is not being forced via the COLLATE
option.
This is not a problem/error most people get because tempdb
nearly always has the same collation as the instance/server and the other system databases (i.e. master
, msdb
, and model
.
Part 2
That brings us to the root cause of the problem: under normal conditions, the collation of tempdb
should nearly always be the same as the instance/server -level collation, as well as the other three system databases. This is handled during installation. (And, I emphasized "nearly" due to contained databases using the database's default collation for string columns in temp tables.)
Somehow your tempdb
collation is different than the instance/server -level collation, as well as the master
and (I assume) msdb
databases. I suspect that the model
database was restored from an instance configured to use SQL_Latin1_General_CP1_CI_AS
(since tempdb
is rebuilt from model
every the time instance starts up).
An easy way to confirm this is to use a modified version of the query I had you execute to get the server and tempdb
collations (this time we will get the collation for model
, perhaps something we should have done the first time around, as well as msdb
just to be sure):
SELECT SERVERPROPERTY('collation') AS [InstanceCollation],
DATABASEPROPERTYEX(N'master', 'collation') AS [MasterDbCollation],
DATABASEPROPERTYEX(N'msdb', 'collation') AS [MSDbCollation],
DATABASEPROPERTYEX(N'model', 'collation') AS [ModelDbCollation],
DATABASEPROPERTYEX(N'tempdb', 'collation') AS [TempDbCollation];
Fix
Hence, to fix this:
You cannot execute ALTER DATABASE [model] COLLATE ....;
, not even when running in Single User mode, since it is a system database.
You will need to restore the model
database from an instance configured to use Latin1_General_BIN
. If you don't have another instance already using Latin1_General_BIN
, then just go through the install process (on a non-production server), select the fewest options possible, and stick with all defaults except for the collation, which should be set to Latin1_General_BIN
.
SELECT SERVERPROPERTY('collation') AS [InstanceCollation], DATABASEPROPERTYEX(N'master', 'collation') AS [SystemDbCollation], DATABASEPROPERTYEX(N'tempdb', 'collation') AS [TempDbCollation];
. Thanks.SELECT @Version = '8.11', @VersionDate = '20221013'
updated to latest version and see if you get any issues ..