March 19, 2017 at 8:34 am
Hi all,
I am trying out to support/insert a different language/character other then the default codepage in the current database which is SQL_Latin1_General_CP1_CI_AS. Thus i am trying to use column collation to support another characterset.
This is what I have tested.
Instance/Database Default CS -> SQL_Latin1_General_CP1_CI_AS create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);
insert into test values ('a','b');
insert into test values ('a','ไกไไกกง');
select * From test;
a b
a ???????
============
If I created another database with the default collation as "Thai_CS_AI" , i have absolutely no problem displaying the result correct.
-- create database thaidb with default collation as "Thai_CS_AI"
create table test(a varchar(20),
b varchar(20) ); -- did not set column collation anymore since DB default is already set so
insert into test values ('a','b');
insert into test values ('a','ไกไไกกง');
select * From test;
a b
a ไกไไกกง
I am using SQL management studio for the above testing.
Why isn't my column collation working =(
Please help~
Regards,
Noob
March 19, 2017 at 1:53 pm
I believe that you need to make it so that the insert is of the collation you desire, as well.
create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);
insert into test values ('a','b');
insert into test values ('a','???????' collate Thai_CS_AI);
select * From test;
The reason you don't need to do that if you make the whole server of that collation is because that affects everything including the inserts.
Not sure, but you may have to use the collation on the column when you do a select from it, as well but haven't tried it.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 22, 2017 at 10:30 am
Jeff Moden - Sunday, March 19, 2017 1:53 PMI believe that you need to make it so that the insert is of the collation you desire, as well.
create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);insert into test values ('a','b');
insert into test values ('a','ไà¸à¹„ไà¸à¸à¸‡' collate Thai_CS_AI);select * From test;
The reason you don't need to do that if you make the whole server of that collation is because that affects everything including the inserts.
Not sure, but you may have to use the collation on the column when you do a select from it, as well but haven't tried it.
Hi Jeff,
Thanks, sorry for the late reply.
Didn't know that we can do a collate on insert as well but well that didn't work also.
Can you let me know how do we specify a collate on SELECT ?
Tried SELECT b collate Thai_CS_AI from tab;
Still failed =(
Regards,
Noob
March 22, 2017 at 10:34 pm
szejiekoh - Wednesday, March 22, 2017 10:30 AMJeff Moden - Sunday, March 19, 2017 1:53 PMI believe that you need to make it so that the insert is of the collation you desire, as well.
create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);
insert into test values ('a','b');
insert into test values ('a','ไà¸à¹„ไà¸à¸à¸‡' collate Thai_CS_AI);
select * From test;The reason you don't need to do that if you make the whole server of that collation is because that affects everything including the inserts.
Not sure, but you may have to use the collation on the column when you do a select from it, as well but haven't tried it.
Hi Jeff,
Thanks, sorry for the late reply.
Didn't know that we can do a collate on insert as well but well that didn't work also.Can you let me know how do we specify a collate on SELECT ?
Tried
SELECT b collate Thai_CS_AI from tab;
Still failed =(Regards,
Noob
[
create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);
insert into test values ('a','b');
insert into test values ('a','ไà¸à¹„ไà¸à¸à¸‡' collate Thai_CS_AI); --Even this won't work
insert into test values ('a',N'ไà¸à¹„ไà¸à¸à¸‡' ); --But this does
select * From test;
Results:
a b
-------------------- --------------------
a b
a ???????
a ไà¸à¹„ไà¸à¸à¸‡
I left the column definitions in the table as they were but you might want to change the "b" column to NVARCHAR just so folks "get it".
--Jeff Moden
Change is inevitable... Change for the better is not.
March 23, 2017 at 6:39 am
Jeff Moden - Wednesday, March 22, 2017 10:34 PMszejiekoh - Wednesday, March 22, 2017 10:30 AMJeff Moden - Sunday, March 19, 2017 1:53 PMI believe that you need to make it so that the insert is of the collation you desire, as well.
create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);
insert into test values ('a','b');
insert into test values ('a','ไà¸à¹„ไà¸à¸à¸‡' collate Thai_CS_AI);
select * From test;The reason you don't need to do that if you make the whole server of that collation is because that affects everything including the inserts.
Not sure, but you may have to use the collation on the column when you do a select from it, as well but haven't tried it.
Hi Jeff,
Thanks, sorry for the late reply.
Didn't know that we can do a collate on insert as well but well that didn't work also.Can you let me know how do we specify a collate on SELECT ?
Tried
SELECT b collate Thai_CS_AI from tab;
Still failed =(Regards,
NoobAh... crud... my bad and my apologies. See the comments in the following. You sometimes have to give it the "Unicode nudge".[
create table test(a varchar(20),
b varchar(20) collate Thai_CS_AI);insert into test values ('a','b');
insert into test values ('a','ไà¸à¹„ไà¸à¸à¸‡' collate Thai_CS_AI); --Even this won't work
insert into test values ('a',N'ไà¸à¹„ไà¸à¸à¸‡' ); --But this doesselect * From test;
Results:
a b
-------------------- --------------------
a b
a ???????
a ไà¸à¹„ไà¸à¸à¸‡(3 row(s) affected)I left the column definitions in the table as they were but you might want to change the "b" column to NVARCHAR just so folks "get it".
Hi Jeff,
Yeap the specification of 'N' did help. But i thought 'N' = unicode. But i can't wrap my head around on how does a "Unicode" encoding be able to insert into a "Thai" encoding column. The thai words have the same code point in both Unicode and Thai encoding ?
Regards,
Noob
March 23, 2017 at 1:26 pm
To be honest, I don't know the answer to your latest question. I have a difficult enough time even getting people to use CR/LF symbols consistently for imports.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 4, 2017 at 7:13 am
Jeff Moden - Thursday, March 23, 2017 1:26 PMTo be honest, I don't know the answer to your latest question. I have a difficult enough time even getting people to use CR/LF symbols consistently for imports.
Hi Jeff,
I am so sorry for the late reply. Your honest reply is more then enough assurance for me.
Thank you!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply