<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to write utf-8 data to SQL server? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/898897#M355289</link>
    <description>&lt;P&gt;Hi, guys!&lt;/P&gt;
&lt;P&gt;I've connect SAS to SQL server and tried&amp;nbsp; to write data to the server. But the Thai characters don't appear as I expected. They appear as "?".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More information:&lt;/P&gt;
&lt;P&gt;The sqlserver running on windows.&lt;/P&gt;
&lt;P&gt;SAS&amp;nbsp;running on unix.&lt;/P&gt;
&lt;P&gt;And the unicode of SAS session is UTF8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How I connected SAS to SQL server&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sslib sqlsvr noprompt="DRIVER=SAS ACCESS to MS SQL Server;
UID=&lt;EM&gt;my UID&lt;/EM&gt; ;PWD&lt;EM&gt;=my Password&lt;/EM&gt;;
HOST&lt;EM&gt;=my Host&lt;/EM&gt; ;PORT=&lt;EM&gt;my Port&lt;/EM&gt; ; db= &lt;EM&gt;my Database&lt;/EM&gt;" schema="dbo";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the data&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mayt_1-1697538112231.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88905i354E4785441A5D8B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Mayt_1-1697538112231.png" alt="Mayt_1-1697538112231.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If I create new table in SQL server from the data&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table sslib.test_temp_output(encoding='utf8') as
	select *
	from work.temp_tbl(encoding='utf8');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How a new table looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mayt_2-1697538283422.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88906iBAA5EE96EAF660BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Mayt_2-1697538283422.png" alt="Mayt_2-1697538283422.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I've tried proc append but the results stay the same.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set temp_tbl(encoding='any');
  put string= $quote. +1 string $hex8.;
run;

proc append base=sslib.test_table data=temp_tbl(encoding='utf8') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set temp_tbl(encoding='any');
  put string= $quote. +1 string $hex8.;
run;

proc append base=sslib.test_table data=temp_tbl(encoding='any') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 10:34:43 GMT</pubDate>
    <dc:creator>Mayt</dc:creator>
    <dc:date>2023-10-17T10:34:43Z</dc:date>
    <item>
      <title>How to write utf-8 data to SQL server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/898897#M355289</link>
      <description>&lt;P&gt;Hi, guys!&lt;/P&gt;
&lt;P&gt;I've connect SAS to SQL server and tried&amp;nbsp; to write data to the server. But the Thai characters don't appear as I expected. They appear as "?".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More information:&lt;/P&gt;
&lt;P&gt;The sqlserver running on windows.&lt;/P&gt;
&lt;P&gt;SAS&amp;nbsp;running on unix.&lt;/P&gt;
&lt;P&gt;And the unicode of SAS session is UTF8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How I connected SAS to SQL server&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sslib sqlsvr noprompt="DRIVER=SAS ACCESS to MS SQL Server;
UID=&lt;EM&gt;my UID&lt;/EM&gt; ;PWD&lt;EM&gt;=my Password&lt;/EM&gt;;
HOST&lt;EM&gt;=my Host&lt;/EM&gt; ;PORT=&lt;EM&gt;my Port&lt;/EM&gt; ; db= &lt;EM&gt;my Database&lt;/EM&gt;" schema="dbo";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the data&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mayt_1-1697538112231.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88905i354E4785441A5D8B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Mayt_1-1697538112231.png" alt="Mayt_1-1697538112231.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If I create new table in SQL server from the data&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table sslib.test_temp_output(encoding='utf8') as
	select *
	from work.temp_tbl(encoding='utf8');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How a new table looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mayt_2-1697538283422.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88906iBAA5EE96EAF660BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Mayt_2-1697538283422.png" alt="Mayt_2-1697538283422.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I've tried proc append but the results stay the same.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set temp_tbl(encoding='any');
  put string= $quote. +1 string $hex8.;
run;

proc append base=sslib.test_table data=temp_tbl(encoding='utf8') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set temp_tbl(encoding='any');
  put string= $quote. +1 string $hex8.;
run;

proc append base=sslib.test_table data=temp_tbl(encoding='any') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 10:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/898897#M355289</guid>
      <dc:creator>Mayt</dc:creator>
      <dc:date>2023-10-17T10:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write utf-8 data to SQL server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/898958#M355315</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439882"&gt;@Mayt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a look at this paper&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/Multilingual_Computing_with_SAS_94.pdf" target="_blank"&gt;Multilingual Computing_with SAS 9.4&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It looks like you would need to declare your SqlServer Tables with nchar/nvchar columns in order to display utf-8 data values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/898958#M355315</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-10-17T15:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to write utf-8 data to SQL server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/899725#M355588</link>
      <description>&lt;P&gt;Can we do it in sas studio?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 08:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/899725#M355588</guid>
      <dc:creator>Mayt</dc:creator>
      <dc:date>2023-10-24T08:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to write utf-8 data to SQL server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/899751#M355599</link>
      <description>Technically speaking yes, by using explicit SQL pass through.&lt;BR /&gt;Here's a Microsoft documentation link:&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-ver16" target="_blank"&gt;https://learn.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-ver16&lt;/A&gt;</description>
      <pubDate>Tue, 24 Oct 2023 10:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/899751#M355599</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-10-24T10:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to write utf-8 data to SQL server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/900872#M356021</link>
      <description>Thank you so much</description>
      <pubDate>Tue, 31 Oct 2023 09:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-write-utf-8-data-to-SQL-server/m-p/900872#M356021</guid>
      <dc:creator>Mayt</dc:creator>
      <dc:date>2023-10-31T09:21:47Z</dc:date>
    </item>
  </channel>
</rss>

