Hello,
I use Unicode in my program to enter data in Chinese into a nvarchar field.
When inserting or updating records, my application does not use Unicode
escape sequences but rather the Unicode characters themselves. Thus, my app
may have SQL statements like:
UPDATE table SET field1 = '<some string in Chinese>';
The syntax above works both in my app and through SQL Server Enterprise
Management. However, if I try the SELECT query below, it fails to match the
record I inserted both in my app and through Enterprise manager:
SELECT * FROM table WHERE field1 = '<some string in Chinese>';
I tried changing the UPDATE statement and the SELECT statement to use escape
sequences instead of the actual unicode characters, but that made things
worse. For example, I executed:
UPDATE table SET field1 = '\u4E0A\u6D77';
SELECT * FROM table WHERE field1 = '\u4E0A\u6D77';
The UPDATE statement actually stored the literal '\u4E0A\u6D77' without
converting it to its Unicode character. The SELECT statement also did not
convert the escape sequence, so it matched the record I inserted but I no
longer have the correct Unicode string stored. I also tried:
UPDATE table SET field1 = N'\u4E0A\u6D77' ;
SELECT * FROM table WHERE field1 = N'\u4E0A\u6D77' ;
with no success either.
Why can I use the Unicode chars explicitly when adding or updating records,
but cannot use them to match a record with a SELECT statement? Is there
something I'm missing when using the escape sequence (maybe some conversion
function) ?
Thanks,
SL 2 7484
[posted and mailed, please reply in news]
Silvio Lopes de Oliveira (si*****@aaesys .com) writes: I use Unicode in my program to enter data in Chinese into a nvarchar field. When inserting or updating records, my application does not use Unicode escape sequences but rather the Unicode characters themselves. Thus, my app may have SQL statements like:
UPDATE table SET field1 = '<some string in Chinese>';
The syntax above works both in my app and through SQL Server Enterprise Management. However, if I try the SELECT query below, it fails to match the record I inserted both in my app and through Enterprise manager:
SELECT * FROM table WHERE field1 = '<some string in Chinese>';
I would expect that you would have to use N'<some string in Chinese>',
or else the string would be converted to fallback characters in your
ANSI character set.
When you look at the data as you updated it, do you see it correctly?
I tried changing the UPDATE statement and the SELECT statement to use escape sequences instead of the actual unicode characters, but that made things worse. For example, I executed:
UPDATE table SET field1 = '\u4E0A\u6D77'; SELECT * FROM table WHERE field1 = '\u4E0A\u6D77';
Of course. This is nothing which is supported by SQL Server. The way
to express that string through codes would be:
select nchar(0x4E0A) + nchar(0x6D77)
Why can I use the Unicode chars explicitly when adding or updating records, but cannot use them to match a record with a SELECT statement? Is there something I'm missing when using the escape sequence (maybe some conversion function) ?
There is no difference to UPDATE and SELECT as far as SQL Server is
concerned. But since you talk about application and Enterprise Manager
there may be things going on at client level.
The best tool to use for simple tests is Query Analyzer, since it
just sends the query to SQL Server and presents the result.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Prefix the string with N.
UPDATE table SET field1 = '<some string in Chinese>';
should be
UPDATE table SET field1 = N'<??????>'; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Irmen de Jong |
last post by:
Hello
I'm having some troubles with PySqlite (0.4.3, windows/linux).
I want to store unicode strings in the database.
So I open a connection with the client_encoding="UTF-8" parameter.
When I store a unicode string in a table, it seems to work fine.
(a sqlite .dump shows that it encoded the unicode string to UTF-8).
But the problem is that a *query* from the same table, doesn't
return the string contents as a unicode string! Rather, it
|
by: Alban Hertroys |
last post by:
Another python/psycopg question, for which the solution is probably
quite simple; I just don't know where to look.
I have a query that inserts data originating from an utf-8 encoded XML
file. And guess what, it contains utf-8 encoded characters...
Now my problem is that psycopg will only accept queries of type str, so
how do I get my utf-8 encoded data into the DB?
I can't do query.encode('ascii'), that would be similar to:
>>> x =...
|
by: |
last post by:
The data file is a simple Unicode file with lines of text. BCP
apparently doesn't guarantee this ordering, and neither does the
import tool. I want to be able to load the data either sequentially or
add line numbering to large Unicode file (1 million lines). I don't
want to deal with another programming language if possible and I
wonder if there's a trick in SQL Server to get this accomplished.
Thanks for any help.
Mark Leary
|
by: Frank van Vugt |
last post by:
Hi,
I noticed that queries from one of my php-clients were failing when they
contained certain accented characters, but upon trying the same thing in
psql, it showed failure there as well. Strangely enough, at least one
character is working o.k.
Could someone enlighten my why....?
(using SuSE v9.0)
|
by: Bill Grigg |
last post by:
I am attempting to set the UnicodeCompression property via code. The
following line "appears" to work:
tdf.Fields("State").Properties("UnicodeCompression").Value =
True
I can see the boolean in the property sheet change from No to Yes.
However, the behavior has not changed at all. It still behaves as
though it were set to No. When I change the boolean in the property
sheet GUI it behaves as expected. Any thoughts?
| |
by: Tomas Machala |
last post by:
Hi,
I'm looking for some way how to make strings with aggresive characters safe
for usement in SQL queries for Microsoft SQL - just something, what would
add slashes before such characters.
Is there any function for that?
Thanks.
|
by: Joshua Morgan |
last post by:
Hey,
Currently me and a friend are coding up a new BitTorrent tracker. We
have a torrents table that has a column called 'info_hash' which
contains the info_hash as received by the announce.php script (this is
used to identify the torrent).
If we have the collation as latin1_general_ci, and I don't send any SET
NAMES OR SET CHARACTER SET queries after connecting, my announce script
can successfully retrieve the row from the torrents...
|
by: Richard Schulman |
last post by:
Sorry to be back at the goodly well so soon, but...
....when I execute the following -- variable mean_eng_txt being
utf-16LE and its datatype nvarchar2(79) in Oracle:
cursor.execute("""INSERT INTO mean (mean_id,mean_eng_txt)
VALUES (:id,:mean)""",id=id,mean=mean)
I not surprisingly get this error message:
|
by: Daz |
last post by:
Hi everyone.
I was faced with the choice of whether my problem is indeed a PHP
problem or a MySQL. I have decided it's a PHP problem as I don't
experience the same problem when I execute the same query at the CLI.
I am having trouble executing a large query through my PHP script. It
takes about 7-11 seconds on
average to execute, whereas the same query only takes 0.01 seconds to
execute through the CLI.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |