Showing posts with label nchar. Show all posts
Showing posts with label nchar. Show all posts

Thursday, March 8, 2012

chinese characters with Unicode data types?

Hi,
I read that Unicode data types (like nchar or nvarchar)
support any characters of any language in the world. As we
need a database that supports many different languages, I
have tried to paste chinese characters into one table
field - although the field's data type is nvarchar, it
pastes only squares (instead of the chinese characters)
Can someone please help?
Thanks in advance,
BodoOne possibility is that the data is actually stored correctly in the
database, but the query tool you are using hasn't been configured to use a
font that defines glyphs for Chinese characters. Try using Query Analyzer
to both insert and view the data (don't use the "Show All Rows" view in
Enterprise Manager as the controls used in this view aren't Unicode aware).
Go to Tools --> Options --> Fonts tab, and select a font that supports
Chinese like "SimSun" or "Arial Unicode MS" for the "Results Text" and
"Results Grid" views.
Bart
--
Please reply to the newsgroup only - thanks.
This posting is provided "AS IS" with no warranties, and confers no rights.
Content-Class: urn:content-classes:message
From: "bodo" <bodobecker@.hotmail.com>
Sender: "bodo" <bodobecker@.hotmail.com>
Subject: chinese characters with Unicode data types?
Date: Sat, 13 Sep 2003 09:11:57 -0700
Lines: 14
Message-ID: <000a01c37a11$c15c4bf0$a401280a@.phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN6EcFc9/ArRhOoTrW8Ejd9PK+XmQ==Newsgroups: microsoft.public.sqlserver.server
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:306274
NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
X-Tomcat-NG: microsoft.public.sqlserver.server
Hi,
I read that Unicode data types (like nchar or nvarchar)
support any characters of any language in the world. As we
need a database that supports many different languages, I
have tried to paste chinese characters into one table
field - although the field's data type is nvarchar, it
pastes only squares (instead of the chinese characters)
Can someone please help?
Thanks in advance,
Bodo

Wednesday, March 7, 2012

checksum() of char, varchar, nchar, nvarchar, or sql_variant

Karam,
checksum and binary_checksum can be used for char, varchar, nchar, and
nvarchar. If you need it for sql_variant, you could convert the
sql_variant value to varbinary before applying the checksum or
binary_checksum. The following works fine for me (SQL Server 2000 sp3).
declare @.t table (
a char(10),
b nchar(10),
c varchar(10),
d nvarchar(10),
e sql_variant
)
insert into @.t values ('abc','def','ghi','jkl',cast(3.2 as sql_variant))
insert into @.t values ('abc','def','ghi','jkl',cast('mno' as sql_variant))
insert into @.t values ('abc','def','ghi','jkl',cast(PI() as sql_variant))
select
checksum(a),
checksum(b),
checksum(c),
checksum(d),
checksum(cast(e as varbinary(8000)))
from @.t
Steve Kass
Drew University
Karam Chand wrote:

>Hello,
>As the books online suggest we cannot generate checksum() value of the above types
using Checksum() or binary_checksum(), but my app requires it. Can somebody tell me
how to do that? Or is it just not possible... Maybe I can use some external program
min
g language?
>Karam
>Karam,
If you include a, b, c, d, and e in the output, it should look fine:
abc 34400 def 1132889051 ghi 40390
jkl -2087894091 3.2 135216
abc 34400 def 1132889051 ghi 40390
jkl -2087894091 mno 27535
abc 34400 def 1132889051 ghi 40390
jkl -2087894091 3.1415926535897931 200148684
You should be aware of the fact that CHECKSUM is not guaranteed to
return different values from different input. There are only
~4000000000 possible checksum values, but far more possible input values.
SK
Karam Chand wrote:

>Hello,
>I tried your query on SQL Server 2000 and checksum is always returning me t
he same value for different set of data. If you execute the checksum() for y
our above data, I am getting result:
>304227412 1174430821 25065 6974316 135216
>304227412 1174430821 25065 6974316 27535
>304227412 1174430821 25065 6974316 200148684
>As you can see, its all same so it is difficult to know the difference?
>Karam
> -- Steve Kass wrote: --
> Karam,
> checksum and binary_checksum can be used for char, varchar, nchar, a
nd
> nvarchar. If you need it for sql_variant, you could convert the
> sql_variant value to varbinary before applying the checksum or
> binary_checksum. The following works fine for me (SQL Server 2000 sp3
).
> declare @.t table (
> a char(10),
> b nchar(10),
> c varchar(10),
> d nvarchar(10),
> e sql_variant
> )
> insert into @.t values ('abc','def','ghi','jkl',cast(3.2 as sql_variant
))
> insert into @.t values ('abc','def','ghi','jkl',cast('mno' as sql_varia
nt))
> insert into @.t values ('abc','def','ghi','jkl',cast(PI() as sql_varian
t))
> select
> checksum(a),
> checksum(b),
> checksum(c),
> checksum(d),
> checksum(cast(e as varbinary(8000)))
> from @.t
> Steve Kass
> Drew University
> Karam Chand wrote:
>
gramming language?
>