I had a recent run in with collation problems and it got me started reading about them. As I read I started to realize that for a seemingly simple subject there was a lot to it. So I thought I would go over some of what I found out.
You’ve installed your instance, created your database, created your tables even started running your queries. And then you realize that at some level or another you’ve made a mistake and now you need to change your collation. This gets more complicated the farther up the chain you go. In particular changing the collation of an instance is a big pain. In fact it is such a big pain I highly recommend not doing it. Plan ahead carefully so that you never have to mess with this. However, since life happens:
Instance
There is no easy way to do this I’m afraid.
- Goes without saying but back up all user and system databases
- Detach all of your user databases
- Script out all of your server principals (logins, user defined roles, certificates etc) and any jobs.
- Back up any DTS packages (hopefully none) and any SSIS packages
- List out any configurations
- Script out any changes to the model database
- Any other changes that you might have made to the original system databases that I might have forgotten. Microsoft has a good list of what to do here: Rebuild System Databases
- Rebuild the system databases using setup and the new collation. See the above link
- Reattach all of the user databases
- Use the methods I mentioned in the previous post to change the collation for each of the databases
Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=InstanceName /SQLSYSADMINACCOUNTS=accounts [ /SAPWD= StrongPassword ] /SQLCOLLATION=CollationName
Over a number of different posts I’m going to discuss some of the surprisingly deep subject of collation.
As a start listen to Rob Farley’s hilarious talk on collation
Collation: Definition
Collation: Location
Collation: Expression
Collation: Correction -> Expression, Column, Database
Collation: Temporary objects & variables: Demonstration
Collation: Confusion
Filed under: Collation, Microsoft SQL Server, SQLServerPedia Syndication, System Databases Tagged: code language, collation, language sql, microsoft sql server, system databases