我想要做的sql語法是將兩個table做union

語法如下

select  1,'' as code, 'aa' as cdesc
from table a where rownum <= 1
union
Select distinct 2,a.col1 ,col2
        From table2 a

但執行後卻一直出現"ORA-12704: 字元設定不符合"

原來是col1的資料型別是nvarchar2的,所以要在下sql 時要在欄位前面冠N

如下,不然會一直出現錯誤

select  N'' as code,  N'aa' as cdesc from table a where rownum <= 1

union

Select  a.col1 ,col2  From table2 a

 

把這個經驗log下來以後可以備查

arrow
arrow
    全站熱搜

    丫德 發表在 痞客邦 留言(1) 人氣()