Tuesday, March 27, 2012

Help with chinese character

sorry.. help with chinese character , cocode is nchar(10)
int (1), i can see the record of that china company, but in (2) , show
nothing...
(1)select cocode,invno ,netbaseamt from arinvinfo order by cocode
(2)select * from arinvinfo where rtrim(cocode) = 'vQ'Agnes,
You need to put N before any Unicode string, or it will
be converted to single-byte characters. It should be
this, with just the small change of adding the N:
select * from arinvinfo where rtrim(cocode) = N'宗利港塑料'
Steve Kass
Drew University
Agnes wrote:

>sorry.. help with chinese character , cocode is nchar(10)
>int (1), i can see the record of that china company, but in (2) , show
>nothing...
>(1)select cocode,invno ,netbaseamt from arinvinfo order by cocode
>(2)select * from arinvinfo where rtrim(cocode) = '宗利港塑料'
>
>|||Thanks Kass.
So for normal english character, I also use N'mycompanyname'
so, I need to correct it in all my store procedure ,right ? (If I use vb.net
. i also need to put N ?)
"Steve Kass" <skass@.drew.edu> glsD:esFp4HtIFHA.2276@.TK2MSFTNGP15.phx.gbl...[color
=darkred]
> Agnes,
> You need to put N before any Unicode string, or it will
> be converted to single-byte characters. It should be
> this, with just the small change of adding the N:
> select * from arinvinfo where rtrim(cocode) = N'vQ'
> Steve Kass
> Drew University
> Agnes wrote:
>|||Agnes,
It is good practice to use N'everything' whenever your data type is
Unicode
(nchar, nvarchar, ntext), but for strings of Latin letters, numbers and
punctuation
in the ASCII character set up to CHAR(127), you can leave it out.
For VB.Net, you can ask in a VB group. The N is for literal strings
specified
in Transact-SQL programs. It is not for every other programming language.
SK
Agnes wrote:

>Thanks Kass.
>So for normal english character, I also use N'mycompanyname'
>so, I need to correct it in all my store procedure ,right ? (If I use vb.ne
t
>. i also need to put N ?)
>"Steve Kass" <skass@.drew.edu> 撰寫於郵件新聞:esFp4HtIFHA.2276@.TK2MSF
TNGP15.phx.gbl...
>
>
>|||Recently, I found out one of query suffered huge performance, and found out
the jdbc driver converts all the query to be N'string', the query without N
is a lot faster. In this case how can you increase the performance if use
N'everything' ? Thanks
"Steve Kass" wrote:

> Agnes,
> It is good practice to use N'everything' whenever your data type is
> Unicode
> (nchar, nvarchar, ntext), but for strings of Latin letters, numbers and
> punctuation
> in the ASCII character set up to CHAR(127), you can leave it out.
> For VB.Net, you can ask in a VB group. The N is for literal strings
> specified
> in Transact-SQL programs. It is not for every other programming language.
> SK
>
> Agnes wrote:
>
>|||Jen,
I don't know the specifics of the situation you
mention, but I do know that if your data is *not*
Unicode, it can be very bad to specify string
literals with N'... . Specifically, if you have
a query like this:
select <columns>
from T
where nonUnicodeColumn = N'UnicodeConstant'
it will be impossible for the query processor to
use an index on charColumn, since the comparison
will be between cast(nonUnicodeColumn as nvarchar(<length> ))
and N'UnicodeConstant'.
If there is nothing causing a type conversion or collation
discrepancy, so long as the columns are Unicode types,
I don't know a reason why it would be a bad idea to use
the N prefix for literal values.
SK
Jen wrote:
> Recently, I found out one of query suffered huge performance, and found ou
t
> the jdbc driver converts all the query to be N'string', the query without
N
> is a lot faster. In this case how can you increase the performance if use
> N'everything' ? Thanks
> "Steve Kass" wrote:
>

No comments:

Post a Comment