Sybase/Sap sql: converting from cp1251 to utf8

431 Views Asked by At

Default charset in base is Windows1251, but when I use "for json" statement, result presents in "utf8"

Is it possible convert some column to ut8, using sql?

I try this code

select 
  1 as "tag",
  null as "parent",
  "period" as "!1!period",
  "nazva" as "!1!nazva",
  "DogovorNumber" as "!1!DogovorNumber"
  from "dba"."Myk_Orgs_for_1C"(@cmonth = 3,@cyear = 2022)
  order by 3 asc for json explicit

But my columns values shown like this "nazva":"ГОРОЯН НАIРА"

1

There are 1 best solutions below

0
On

You can workaround the encoding issue with output statement:

select 
  1 as "tag",
  null as "parent",
  "period" as "!1!period",
  "nazva" as "!1!nazva",
  "DogovorNumber" as "!1!DogovorNumber"
  from "dba"."Myk_Orgs_for_1C"(@cmonth = 3,@cyear = 2022)
  order by 3 asc for json explicit
;
output to 'C:\\out.json' format text escapes on escape character '\' delimited by '' encoding 'CP-1251'