SQL Server multi language data support

蹲街弑〆低调 提交于 2019-12-19 03:07:08

问题


How do you setup a SQL Server 2005 DBMS, so that you can store data in different languages?

My exact problem is this: in SQL Server Management Studio I'm writing an insert statement which contains German Umlauts. Text is successfully saved but reading the same value results in text without Umlaut.

Consider that I have to support 4 languages: English, German, Greek & Russian (I don't want to think what I will face with the Russian text).

The DBMS is now setup with Greek collation (to support Greek).

Does this cause any problem??

Any hints??


回答1:


You need to use nvarchar data type for strings ( http://msdn.microsoft.com/en-us/library/ms186939.aspx ) and you also need to precede all unicode strings with N ( http://support.microsoft.com/kb/239530 ).

When dealing with Unicode string constants in SQL Server you must precede all Unicode strings with a capital letter N, as documented in the SQL Server Books Online topic "Using Unicode Data". The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.




回答2:


are you using nvarchar type (rather than varchar)? would be recommended if you have multiple langs in the same column. that will let you store and retrieve properly.

of course, sql server can only maintain one collation type on a particular column, even if the column is being used to store strings in multiple languages, so that is something to consider...



来源:https://stackoverflow.com/questions/2017198/sql-server-multi-language-data-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!