<?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 CASLIB Connection to SQL Server Fails to Load Rows with VARCHAR(MAX) Column in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/967706#M2864</link>
    <description>&lt;P&gt;Hey!&lt;BR /&gt;Viya 3.5&lt;BR /&gt;I'm facing an issue when trying to load a table from Microsoft SQL Server into CAS using a CASLIB data connector. My SQL Server table contains a column with the &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; data type, which stores very large text fields (up to 3 million characters).&lt;/P&gt;&lt;P&gt;When I try to load the table into CAS, the process completes without errors, but the resulting CAS table has zero rows. If I use the connection wizard in SAS Studio, it also fails to show any sample data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using:&lt;/P&gt;&lt;PRE&gt;caslib sqlDB desc='Microsoft SQL Server Caslib' 
    dataSource=(srctype='sqlserver',
                username='user1',
                password='myPwd',
                sqlserver_dsn="configured-DSN-name",
                catalog='*');

proc casutil;
  load casdata="myTable" incaslib="sqlDB" 
       casout="myCASTable" outcaslib="casuser";
run;&lt;/PRE&gt;&lt;P&gt;As suggested in&lt;LI-MESSAGE title="Read varchar(max) from SQL Server into SAS." uid="755583" url="https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755583#U755583" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;BR /&gt;As a test, I created a new table in the SQL Server database by selecting all data from the original table, but casting the &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; column to &lt;CODE&gt;VARCHAR(8000)&lt;/CODE&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 491px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107428iFDD9D5D2E393829E/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Why does the load fail with a &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; column but succeed with &lt;CODE&gt;VARCHAR(8000)&lt;/CODE&gt;? Is there a specific configuration or option required to make the SAS/ACCESS to SQL Server connector handle &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; data types correctly when loading to CAS?&lt;BR /&gt;The encoding has anything to do with it?&lt;/P&gt;&lt;P&gt;Any help or insight would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Thu, 29 May 2025 11:55:48 GMT</pubDate>
    <dc:creator>cristianstoe</dc:creator>
    <dc:date>2025-05-29T11:55:48Z</dc:date>
    <item>
      <title>CASLIB Connection to SQL Server Fails to Load Rows with VARCHAR(MAX) Column</title>
      <link>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/967706#M2864</link>
      <description>&lt;P&gt;Hey!&lt;BR /&gt;Viya 3.5&lt;BR /&gt;I'm facing an issue when trying to load a table from Microsoft SQL Server into CAS using a CASLIB data connector. My SQL Server table contains a column with the &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; data type, which stores very large text fields (up to 3 million characters).&lt;/P&gt;&lt;P&gt;When I try to load the table into CAS, the process completes without errors, but the resulting CAS table has zero rows. If I use the connection wizard in SAS Studio, it also fails to show any sample data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using:&lt;/P&gt;&lt;PRE&gt;caslib sqlDB desc='Microsoft SQL Server Caslib' 
    dataSource=(srctype='sqlserver',
                username='user1',
                password='myPwd',
                sqlserver_dsn="configured-DSN-name",
                catalog='*');

proc casutil;
  load casdata="myTable" incaslib="sqlDB" 
       casout="myCASTable" outcaslib="casuser";
run;&lt;/PRE&gt;&lt;P&gt;As suggested in&lt;LI-MESSAGE title="Read varchar(max) from SQL Server into SAS." uid="755583" url="https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755583#U755583" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;BR /&gt;As a test, I created a new table in the SQL Server database by selecting all data from the original table, but casting the &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; column to &lt;CODE&gt;VARCHAR(8000)&lt;/CODE&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 491px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107428iFDD9D5D2E393829E/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Why does the load fail with a &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; column but succeed with &lt;CODE&gt;VARCHAR(8000)&lt;/CODE&gt;? Is there a specific configuration or option required to make the SAS/ACCESS to SQL Server connector handle &lt;CODE&gt;VARCHAR(MAX)&lt;/CODE&gt; data types correctly when loading to CAS?&lt;BR /&gt;The encoding has anything to do with it?&lt;/P&gt;&lt;P&gt;Any help or insight would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 11:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/967706#M2864</guid>
      <dc:creator>cristianstoe</dc:creator>
      <dc:date>2025-05-29T11:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: CASLIB Connection to SQL Server Fails to Load Rows with VARCHAR(MAX) Column</title>
      <link>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/967709#M2865</link>
      <description>&lt;P&gt;I suspect that it's because this data type conversion (from MSsql to CAS) is not supported. If you take a look into this doc. page:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_063/casref/n09w43elndibwun1q5iy7wae5yy5.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/v_063/casref/n09w43elndibwun1q5iy7wae5yy5.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;the "Supported Microsoft SQL Server Data Types" table doesn't list varchar(max).&lt;/P&gt;
&lt;P&gt;But, as I wrote, that's just my best guess from what I can see in the doc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 13:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/967709#M2865</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-05-29T13:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: CASLIB Connection to SQL Server Fails to Load Rows with VARCHAR(MAX) Column</title>
      <link>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/968998#M2882</link>
      <description>&lt;P&gt;The&amp;nbsp; MS SQL varchar(max) supports upto 2 GB of data whereas the Viya varchar(*) can support upto&amp;nbsp;&lt;SPAN&gt;536,870,911 characters. That could be one reason for the issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 17:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/CASLIB-Connection-to-SQL-Server-Fails-to-Load-Rows-with-VARCHAR/m-p/968998#M2882</guid>
      <dc:creator>thesasuser</dc:creator>
      <dc:date>2025-06-13T17:46:40Z</dc:date>
    </item>
  </channel>
</rss>

