views:

53

answers:

3

I need to insert chinese characters in my database but it always show ???? ..

Example:

Insert this record.

微波室外单元-Apple

Then it became ???

Result:

??????-Apple

I really Need Help...thanks in regard.

I am using MSSQL Server 2008

A: 

Make sure that you have set an encoding for the database to one that supports these characters. UTF-8 is the de facto encoding as it's ASCII compatible but supports all 1114111 Unicode code points.

Delan Azabani
How to set UTF-8?
Crimsonland
SQL Server doesn't do UTF-8. It's a Microsoft thing, they always want you to use UTF-16 for Unicode instead, which means using the `NVARCHAR` etc string types.
bobince
Gah, that sucks. Sorry, I didn't know that as I come from a general/MySQL background.
Delan Azabani
+2  A: 

Make sure the column you're inserting to is nchar, nvarchar, or ntext. If you insert a Unicode string into an ANSI column, you really will get question marks in the data.

Also, be careful to check that when you pull the data back out you're not just seeing a client display problem but are actually getting the question marks back:

SELECT Unicode(YourColumn), YourColumn FROM YourTable

Note that the Unicode function returns the code of only the first character in the string.

Once you've determined whether the column is really storing the data correctly, post back and we'll help you more.

Emtucifor
A: 

Try adding the appropriate languages to your Windows locale setings. you'll have to make sure your development machine is set to display Non-Unicode characters in the appropriate language. And ofcourse u need to use NVarchar for foreign language feilds

FosterZ