<?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>Question Re: Simple SQL in SSMS returns blank rows in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079977#M4513161</link>
    <description>&lt;P&gt;That works perfect!  Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2019 14:20:38 GMT</pubDate>
    <dc:creator>rwong_gnb</dc:creator>
    <dc:date>2019-12-16T14:20:38Z</dc:date>
    <item>
      <title>Simple SQL in SSMS returns blank rows</title>
      <link>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaq-p/12079973</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I created a linked server connection to our SAP B1 HANA server in my SSMS environment and have been using it for various queries for a while - never had any issues. This week I typed in this simple query into SSMS:&lt;/P&gt;
  &lt;P&gt;SELECT * FROM OPENQUERY([LINKEDSERVERCONNECTION], 'SELECT T0."ItemCode", T0."UserText" FROM DATABASE.OITM T0;')&lt;/P&gt;
  &lt;P&gt;What I got was 99% blank cells with a seemingly random few cells with actual ItemCodes. (see following screenshot)&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1754831-screenshot1.jpg" /&gt;&lt;/P&gt;
  &lt;P&gt;The column UserText &lt;STRONG&gt;IS &lt;/STRONG&gt;showing properly though - when I scroll through I can recognize values but the corresponding ItemCode is blank when it should be the correct part number. &lt;/P&gt;
  &lt;P&gt;Now when I remove T0."UserText" from the query then all the ItemCodes show up:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1754832-screenshot2.jpg" /&gt;&lt;/P&gt;
  &lt;P&gt;So it seems that adding T0."UserText" to the query causes some strange problem returning data.&lt;/P&gt;
  &lt;P&gt;While few ItemCodes have something in UserText compared to all the other ItemCodes, those that do have data can sometimes have quite lengthy strings in UserText (sometimes 100+ characters). However, I do not believe there are enough instances of this to cause what I would believe to be a shortage of resources on the HANA server - but then I'm not a HANA systems expert.&lt;/P&gt;
  &lt;P&gt;If I query ItemCode and UserText in SAP B1's Query Wizard, I can get everything to display correctly. I need it to work in SSMS however.&lt;/P&gt;
  &lt;P&gt;Does anyone have any idea what could be causing SSMS' troubles displaying the query with UserText?&lt;/P&gt;
  &lt;P&gt;Thanks!&lt;/P&gt;
  &lt;P&gt;Randy&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 20:46:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaq-p/12079973</guid>
      <dc:creator>rwong_gnb</dc:creator>
      <dc:date>2019-12-10T20:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Simple SQL in SSMS returns blank rows</title>
      <link>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079974#M4513158</link>
      <description>&lt;P&gt;Hi Randy,&lt;/P&gt;&lt;P&gt;Could you please test this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * 
FROM OPENQUERY([LINKEDSERVERCONNECTION], 
     'SELECT T0."ItemCode"
           , CAST(T0."UserText" AS NVARCHAR(MAX)) AS UserText
      FROM DATABASE.OITM T0;')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 07:13:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079974#M4513158</guid>
      <dc:creator>Johan_Hakkesteegt</dc:creator>
      <dc:date>2019-12-11T07:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Simple SQL in SSMS returns blank rows</title>
      <link>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079975#M4513159</link>
      <description>&lt;P&gt;Hi Johan,&lt;/P&gt;&lt;P&gt;Thanks for the help!  I tried the query and got this error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;OLE DB provider "MSDASQL" for linked server "DATABASE" returned message "[SAP AG][LIBODBCHDB DLL][HDBODBC] General error;260 invalid column name: MAX: line 1 col 54 (at pos 53)".
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT T0."ItemCode", CAST(T0."UserText" AS NVARCHAR(MAX)) AS "UserText" FROM DATABASE.OITM T0;" for execution against OLE DB provider "MSDASQL" for linked server "LINKEDSERVERCONNECTION". 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which is weird - I tried copying &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT T0."ItemCode", CAST(T0."UserText" AS NVARCHAR(MAX)) AS "UserText" FROM DATABASE.OITM T0;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;directly into SAP's query builder and got the same error too.&lt;/P&gt;&lt;P&gt;I tried changing MAX to 4000 (anything higher than that and I get errors - see below) and &lt;STRONG&gt;was able to get it to work&lt;/STRONG&gt; - maybe B1 doesn't use MAX for NVARCHAR cast lengths? &lt;/P&gt;&lt;P&gt;On a side note, I thought the max length for NVARCHAR in HANA was 5000 but when I use 5000 the query runs for half a second and then delivers an error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;OLE DB provider "MSDASQL" for linked server "DATABASE" returned message "Requested conversion is not supported.".
Msg 7341, Level 16, State 2, Line 1
Cannot get the current row value of column "[MSDASQL].UserText" from OLE DB provider "MSDASQL" for linked server "DATABASE". 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the end, I can live with 4000 since our users realistically max out around 1000 - there's a paranoid part of me that wants MAX to work to cover all possible character lengths though.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 14:49:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079975#M4513159</guid>
      <dc:creator>rwong_gnb</dc:creator>
      <dc:date>2019-12-11T14:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Simple SQL in SSMS returns blank rows</title>
      <link>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079976#M4513160</link>
      <description>&lt;P&gt;Hi Randy,&lt;/P&gt;&lt;P&gt;You can try casting it to NTEXT:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CAST(T0."UserText" AS NTEXT) AS UserText&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 07:26:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079976#M4513160</guid>
      <dc:creator>Johan_Hakkesteegt</dc:creator>
      <dc:date>2019-12-12T07:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Simple SQL in SSMS returns blank rows</title>
      <link>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079977#M4513161</link>
      <description>&lt;P&gt;That works perfect!  Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 14:20:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/simple-sql-in-ssms-returns-blank-rows/qaa-p/12079977#M4513161</guid>
      <dc:creator>rwong_gnb</dc:creator>
      <dc:date>2019-12-16T14:20:38Z</dc:date>
    </item>
  </channel>
</rss>

