<?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 Re: Extract SQL Server data with NVARCHAR(max) data type in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399410#M96731</link>
    <description>&lt;P&gt;DBMAX_TEXT is also a dataset option. Have you tried this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	connect to odbc("Driver=ODBC Driver 11 for SQL Server;Server=SQLSVR;Database=MYDB;uid=user;pwd=pwd;");
	create table extract(compress=no dbmax_text = 32767) as
	select * from connection to odbc
	(
		select * from mysch.mytbl
	);
	disconnect from odbc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will still have a problem with text &amp;gt; 32767 characters though.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Sep 2017 06:14:22 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2017-09-28T06:14:22Z</dc:date>
    <item>
      <title>Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399384#M96721</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script which extract data from a MS SQL table. However I'm getting a UCS-2 transcoding error as I have a column with a nvarchar(max) data type. I have some records with more than 32000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a syntax for my proc sql script that I can define the dbmax_text? I know for libname I'll be able to add the dbmax_text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	connect to odbc("Driver=ODBC Driver 11 for SQL Server;Server=SQLSVR;Database=MYDB;uid=user;pwd=pwd;");
	create table extract(compress=no) as
	select * from connection to odbc
	(
		select * from mysch.mytbl
	);
	disconnect from odbc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 02:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399384#M96721</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2017-09-28T02:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399388#M96722</link>
      <description>As far as I know 32k is the maximum number of chars a variable can store. I am sure, that others had the same problem before, so maybe the search function reveals possibilities to solve the problem.</description>
      <pubDate>Thu, 28 Sep 2017 03:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399388#M96722</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-09-28T03:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399410#M96731</link>
      <description>&lt;P&gt;DBMAX_TEXT is also a dataset option. Have you tried this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	connect to odbc("Driver=ODBC Driver 11 for SQL Server;Server=SQLSVR;Database=MYDB;uid=user;pwd=pwd;");
	create table extract(compress=no dbmax_text = 32767) as
	select * from connection to odbc
	(
		select * from mysch.mytbl
	);
	disconnect from odbc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will still have a problem with text &amp;gt; 32767 characters though.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 06:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399410#M96731</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-09-28T06:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399669#M96824</link>
      <description>&lt;P&gt;As a workaround I had to split the column to 16k each on my sql query then concatenate them when creating the sas dataset and assigning a length of 32000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My next problem now is to resolve the same transcoding error when writing the processed data back to sql. I'm using a proc append to a sql table. In my libname I have defined dbmax_text=32000 in my libname statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base=sqllib.myoutput data=extract_processed force; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there other workarounds for this or I really won't be able to writeback a 32k length field into a nvarchar(max) datatype in sql?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 01:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399669#M96824</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2017-09-29T01:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399686#M96828</link>
      <description>&lt;P&gt;Please post the log with the errors.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 03:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/399686#M96828</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-09-29T03:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/401574#M97452</link>
      <description>&lt;P&gt;Sorry I'm unable to extract the whole log as it's residing on a client machine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But error I get is this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR: Unable to transcode data to/from UCS-2 encoding.&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 01:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/401574#M97452</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2017-10-06T01:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extract SQL Server data with NVARCHAR(max) data type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/402115#M97618</link>
      <description>&lt;P&gt;See &lt;A href="http://support.sas.com/kb/40/566.html" target="_blank"&gt;http://support.sas.com/kb/40/566.html&lt;/A&gt; and &lt;A href="http://support.sas.com/kb/47/787.html" target="_blank"&gt;http://support.sas.com/kb/47/787.html&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Your problem looks like those described in the linked pages: mismatching encodings. I recommend contacting tech support.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Oct 2017 20:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-SQL-Server-data-with-NVARCHAR-max-data-type/m-p/402115#M97618</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-07T20:25:42Z</dc:date>
    </item>
  </channel>
</rss>

