Re: UNICODE data in a SQL statement encoded with ANSI character sequence....
From: Bart Duncan [MSFT] (bartd_at_online.microsoft.com)
Date: 07/01/04
- Next message: Chris: "Re: problem with a join"
- Previous message: Robert Taylor: "Re: Troubleshooting sp with transactions..."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 01 Jul 2004 23:17:52 GMT
The most compact way would be to simply send the actual Unicode
characters to SQL so that they didn't have to be encoded numerically. It
is possible to insert Unicode data as a raw binary value, but you have to
be careful to byte swap each character because SQL runs on x86, which is
a little endian processor architecture. For example, the Unicode
character U+3478 is actually represented in memory as 0x7834 (the order
of the two bytes is reversed). The two-character Unicode string U+3478
followed by U+2976 would be 0x78347629 (represented in hex). You could
insert this into an nvarchar column in SQL using: INSERT INTO tbl VALUES
(0x78347629).
HTH,
Bart
------------
Bart Duncan
Microsoft SQL Server Support
Please reply to the newsgroup only - thanks.
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "Donovan J. Edye" <donovan@edye.wattle.id.au>
Subject: Re: UNICODE data in a SQL statement encoded with ANSI character
sequence....
References: <enRf39rWEHA.3716@TK2MSFTNGP11.phx.gbl>
<O4vjPHwWEHA.2616@cpmsftngxa10.phx.gbl>
User-Agent: XanaNews/1.16.3.1
Message-ID: <ueNcrwwWEHA.1888@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.sqlserver.programming
Date: Fri, 25 Jun 2004 16:28:48 -0700
NNTP-Posting-Host: 203-217-58-114.dyn.iinet.net.au 203.217.58.114
Lines: 1
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP
11.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.programming:453422
X-Tomcat-NG: microsoft.public.sqlserver.programming
Bart Duncan [MSFT] wrote:
> SQL doesn't understand escape sequences like #3478. You could
> potentially use the NCHAR function like so:
>
> UPDATE tblMyTable SET MyUnicodeField = NCHAR (0x3478) + NCHAR
> (0x2976)
>
> HTH,
> Bart
Thanks for that, it looks like a plan. I was wondering however if it
was possible to do a single conversion rather than NCHAR() + NCHAR()
etc. but instead NTEXT(0x34780x2976) or similair. I need to send this
data over a comms link so am trying to make it as small as possible.
--D
- Next message: Chris: "Re: problem with a join"
- Previous message: Robert Taylor: "Re: Troubleshooting sp with transactions..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|