12

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

Crimsonland
  • 2,194
  • 3
  • 24
  • 42
  • can u please mention which SQL version you using, i.e MSSql-2002 or MSSql2005 or MSSql-2008 – FosterZ Sep 10 '10 at 03:59
  • 1
    What is a "Microwave outdoor unit"? (compliments of translate.google.com) – ErikE Sep 10 '10 at 04:11
  • Any chance you could share with us what the solution was for you? Was it the need for a unicode column (or "native" as the n in nvarchar means)? – ErikE Sep 13 '10 at 23:54
  • What i ve done is to add eastern language on regional settings on control panel on winsows xp. after that i just change my data type to nvarchar and it works to display Chinese Character on Report. :) – Crimsonland Sep 14 '10 at 00:08

5 Answers5

15

Make sure you specify a unicode string with a capital N when you insert like:

INSERT INTO Table1 (Col1) SELECT N'微波室外单元-Apple' AS [Col1]

and that Table1 (Col1) is an NVARCHAR data type.

Spudley
  • 166,037
  • 39
  • 233
  • 307
matt karp
  • 159
  • 1
  • 2
6

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.

ErikE
  • 48,881
  • 23
  • 151
  • 196
3

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
  • 3,863
  • 6
  • 38
  • 62
0

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
  • 79,602
  • 28
  • 170
  • 210
  • 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 Sep 10 '10 at 11:23
  • Gah, that sucks. Sorry, I didn't know that as I come from a general/MySQL background. – Delan Azabani Sep 10 '10 at 11:53
-1
SELECT 'UPDATE table SET msg=UNISTR('''||ASCIISTR(msg)||''') WHERE id='''||id||''' FROM table WHERE id= '123344556' ;
Ruli
  • 2,592
  • 12
  • 30
  • 40
My Mickei
  • 9
  • 3
  • 2
    Welcome to StackOverflow. While this code may solve the question, [including an explanation](https://meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit](https://stackoverflow.com/posts/64340533/edit) your answer to add explanations and give an indication of what limitations and assumptions apply. – Ruli Nov 10 '20 at 11:11
  • Also this seem as not valid sql syntax – Ruli Nov 10 '20 at 11:15