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

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:
>

Monday, March 26, 2012

Help With Another Query

Hello and Thank You for your previous help,
I have a table simular to the following:
ID = int (Key)
Name= VarChar
Department = nChar
Example Data
ID Name Department
1 Chuck A
2 Mark A
3 Chuck T
4 Chuck S
5 Mark S
I am looking for a query that will Return
Name All Departments
Chuck ATS
Mark AS
Without duplicate Names.
Thanks,
ChuckHi
I'd prefer doing such things on the client side
create table w
(
id int,
t varchar(50) NOT NULL
)
insert into w values (1,'abc')
insert into w values (1,'def')
insert into w values (1,'ghi')
insert into w values (2,'ABC')
insert into w values (2,'DEF')
select * from w
create function dbo.fn_my ( @.id int)
returns varchar(100)
as
begin
declare @.w varchar(100)
set @.w=''
select @.w=@.w+t+',' from w where id=@.id
return @.w
end
select id,
dbo.fn_my (dd.id)
from
(
select distinct id from w
)
as dd
drop function dbo.fn_my
"Charles A. Lackman" <Charles@.CreateItSoftware.net> wrote in message
news:OrLlfeQXHHA.996@.TK2MSFTNGP02.phx.gbl...
> Hello and Thank You for your previous help,
> I have a table simular to the following:
> ID = int (Key)
> Name= VarChar
> Department = nChar
> Example Data
> ID Name Department
> 1 Chuck A
> 2 Mark A
> 3 Chuck T
> 4 Chuck S
> 5 Mark S
> I am looking for a query that will Return
> Name All Departments
> Chuck ATS
> Mark AS
> Without duplicate Names.
> Thanks,
> Chuck
>