title: OLE DB provider 'for linked server returned data that does not match expected data length for
body: <p>I get an error querying a remote postgresql server from my sql server 2017 Standard via a linked server</p>
  
  <p>this is the query:</p>
  
  <pre><code>    SELECT CAST(test AS VARCHAR(MAX))  FROM  OpenQuery(xxxx, 
       'SELECT  corpo::TEXT as test From public.notification')
  </code></pre>
  
  <p>and this is the error message:</p>
  
  <pre><code>    Msg 7347, Level 16, State 1, Line 57
      OLE DB provider 'MSDASQL' for linked server 'xxx' returned data that                 does not match expected data length for 
      column '[MSDASQL].test'. The (maximum) expected data length is 1024,         while the returned data length is 7774.
  </code></pre>
  
  <p>Even without conversions the error stills</p>
  
  <p>For the odbc and linked server I followed this handy <a href="https://www.mssqltips.com/sqlservertip/3662/sql-server-and-postgresql-linked-server-configuration--part-2/." rel="noreferrer">guide</a>.</p>