First SMT release of 2023
by Jiri Dolezalek on 10/01/2023First SMT release of 2023 has been made available
Read moreRecently 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
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.
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.
Michal Tinthofer is the face of the Woodler company which (as he does), is fully committed to complete support of Microsoft SQL Server products to its customers. He often acts as a database architect, performance tuner, administrator, SQL Server monitoring developer (Woodler SMT) and, last but not least, a trainer of people who are developing their skills in this area. His current "Quest" is to help admins and developers to quickly and accurately identify issues related to their work and SQL Server runtime.
First SMT release of 2023 has been made available
Read moreWe will be releasing SMT 1.4 in the next couple of days.
Read moreAnother changes to SMT are done and ready for the release
Read more