Question :
I have a MS SQL Server 2012 instance preinstalled on a Windows 2012 R2 production server. The Windows locale was English(EN-US), and SQL Server Collation is SQL_Latin1_General_CP1_CI_AS. The system handles all Chinese data with nvarchar fields just fine.
Later for some reason (unrelated to sql server) I may have to change default system locale of the Windows 2012 R2 server to Chinese. Will this cause any undesired side effect on the SQL server instance ?
Answer :
In general you should be ok. The only area that I am aware of that could be affected is SQLCLR, in which case the following conditions must be true:
-
(
The LCID of the OS does not match the LCID of the default Collation of the Database where the Assembly is loaded,OR
-
The default Collation of the Database where the Assembly is loaded is either a binary Collation, or is any combination of the following: case-sensitive, accent-insensitive, width-sensitive, or Kana-type-sensitive
),AND
-
custom SQLCLR code is being used
SqlString
is being used as an input parameter type- The
SqlString
parameter is being concatenated inline with astring
while not using either theValue
property or theToString()
method (i.e."some string" + SqlStringInputParam;
) - Or, possibly using Regular Expressions /
Regex
.
To be clear, this issue relates to the default Collation of the Database in which the Assembly is loaded, not the Instance- / Server- level Collation, nor even the Collation of any string column or any string literal or variable with a Collation set via the COLLATE
keyword.
If your Database has a default Collation of SQL_Latin1_General_CP1_CI_AS
because that is what the Instance-level Collation is, then neither # 1 nor # 2 above are true. And in that case, IF there is any SQLCLR code in that Database that matches items 4 – 6 above, then you wouldn’t see any problem. BUT, changing the Locale of the OS would make item # 1 above true, in which case if there is any SQLCLR code that matches item 4 – 6 above, then that code will start to throw “Collation mismatch” exceptions.
Admittedly there is a fairly low probability of running into this. But, it has happened, so it’s best to be aware of it.
Nothing will happen to your SQL Server installation if you change the Windows system locale, because it was installed with the specific collation SQL_Latin1_General_CP1_CI_AS
.