I had a question from a client last week about the “Invariant Language (Invariant Country)” issue that can suddenly appear in a Sitecore solution. I ran into this problem during my very first Sitecore build and got some excellent advice from Sitecore support that I have used ever since.
From a technical point of view, the Invariant language is actually a version of an item that is created with an empty language. So if you were to look at the Invariant language version in the database it would have an empty language field instead of a language like “en”.
From a practical point of view, this issue commonly appears if items are added via a Sitecore package that contains languages that are not included in your Sitecore solution (ie: Not listed under “/sitecore/system/Languages“). I also saw this issue when attempting to change the language in a pre-existing solution.
In order to first diagnose the issue you can run these 2 SQL queries on the Master database to identify how many items contain an Invariant language.
SELECT * FROM [VersionedFields] WHERE [Language] = '' SELECT * FROM [UnversionedFields] WHERE [Language] = ''
After you get a handle on the situation you can then run the following SQL queries on the Master database to remove any versions that contain an empty language field.
DELETE FROM [VersionedFields] WHERE [Language] = '' DELETE FROM [UnversionedFields] WHERE [Language] = ''
These simple queries have served me well over the years since the issue pops up every so often. It’s defintely a good idea to be aware of the Invariant Language issue and it’s even better if you can explain the cause of the issue when asked by a client!
As always, be careful when directly manipulating the database. Backups are, and always will be, you friend!