Recently one of my clients got an issue with collation conflict when he wanted to access properties of his database via SSMS. Issue looks like this:

 

Cause:

Error means that tempdb as a different collation (more restrictive) than collation of user database. So server cannot load properties to the temp db because data can be truncated. Remember that server will always try to protect you when some of your actions will lead to data truncation.

Solution:

Microsoft recommend to "repair installation"

Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=InstanceName 
/SQLSYSADMINACCOUNTS=accounts /[ SAPWD= StrongPassword ] 
/SQLCOLLATION=CollationName

More here:

But be alerted! It means your system databases will be deleted and created from the scratch, so you will lose all data from those db's.

I think there is more simple and harmless way. First we need to understand the process of tempdb collation setting. Tempdb is rebuilding every instance restart from model db. So if we change collation of model db, server will create tempdb with new collation after instance reboot. But there is one caveat. Collation of model db cannot be changed, because it is a system database. This collation has been set when you install SQL instance.

I see two options here.

  1. We could install new SQL server instance somewhere on test and in installation setup pick correct collation. In my case it was Czech_CI_AS. Then shutdown affected instance and newly installed instance. Rename model.mdf and model.ldf files on old instance, then copy model db files from newly installed instance. Start the affected instance and check if the issue persists. If looks ok, you can uninstall new instance and remove renamed old model files after few days.

Remember that you need to have exact same version of model db on both instances.

Don’t forget to check whether server versions are same before moving model using:


 We could try to bypass process of installation using this approach.

1. Stop SQL Service

2. Make a copy of model database for data (model.mdf --> model_old.mdf) and log file (modellog.ldf --> model_old_log.ldf)

3. Start SQL Server and then Attach modelold

4. Run  SQL command as below to change the collation

5.Detach modelold and stop SQL server

 

6.Move model.mdf and modellog.ldf to backup folder.

7.Rename model_old.mdf --> model.mdf and model_old_log.ldf --> modellog.ldf

8.Start sql server and run following to ensure tempdb is working in new collation:

NOTE: Full script: CollationConflict.sql

So in this way we just change model db and not affect other system databases by "repairing" them. If you using different strategy, share it bellow in comments.

More tips and tricks

Storage throughput over time
by Michal Tinthofer on 10/01/2012

Sometimes is nice to have a tool/report which could allow you to see how much your backup storage is degraded over time. Especially by fragmentation and auto growth/shrink operations.

Read more
Load Factor – Uneven load distribution
by Michal Kovaľ on 15/06/2022

Recently, we found an interesting pattern during exploring one of our SMT graphs while doing a health check of a SQL server. The following graph shows us the Load Factor attribute. The value came from system table sys.dm_os_schedulers, which the SMT tool

Read more
SMT 00.5.34 Released!
by Michal Tinthofer on 18/10/2017

Today we introduce to you another patch which was focused on several “quality of life “improvements. Let's have a look!

Read more