例如表1它的编码为gb2312
select * from 表1
那么它输出的结果是gb2312的
现在就想用什么方法使
select * from 表1
的输出结果是UTF-8的编码
不想改该表的编码结构

解决方案 »

  1.   

    char(),varchar(),text()非unicode
    nchar(),nvarchar(),ntext()unicode
      

  2.   

    SQL里好像不认这些东西,它只管 ASC 或者 unicode.只在排序时与它有点关系.
      

  3.   

    只能限定排序规则.如:
    例1:让表NAME列的内容按拼音排序:create table #t(id int,name varchar(20)) 
    insert #t select 1,'中' 
    union all select 2,'国' 
    union all select 3,'人' 
    union all select 4,'阿'select * from #t order by name collate Chinese_PRC_CS_AS_KS_WS 
    drop table #t 
    /*结果: 
    id name 
    ----------- -------------------- 
    4 阿 
    2 国 
    3 人 
    1 中 
    */  例2:让表NAME列的内容按姓氏笔划排序:create table #t(id int,name varchar(20))insert #t select 1,'三' 
    union all select 2,'乙' 
    union all select 3,'二' 
    union all select 4,'一' 
    union all select 5,'十' 
    select * from #t order by name collate Chinese_PRC_Stroke_CS_AS_KS_WS 
    drop table #t 
    /*结果: 
    id name 
    ----------- -------------------- 
    4 一 
    2 乙 
    3 二 
    5 十 
    1 三 
    */