简体   繁体   中英

SQL Server, how to set the default collation to unicode?

I've a WPF+WCF application which works good for now 2 years, but now they have one needs: They want to enter some data in the database, which isn't in the european alphabet(eg cyrillic).

The problem is that the database as a collation set to Latin1_General_CI_AS_WS, and when I store data in it(eg вмешательство), and retrieve them, I got some "??????" instead(When going in the SQL Server Management studio).

The rest of the application already knows working with other kind of alphabet(not for direction of reading, but not my direct problem).

So how can I set the collation to unicode, in an existing database? The collation field is in gray in the SQL Server management studio.

I'm using EntityFramework for all my communication with the database, and I also got those "????" if I retrieve any fields.

Your problem is not collation, it is data type.

As noted in the comments, you are using varchar(x) and text . These types do not store unicode data. You need to be using nvarchar(x) and ntext instead. (if you are on SQL 2005 or newer, you should use nvarchar(MAX) instead of ntext )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM