<?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: Sql Server Join Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309572#M709121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that when you use SQL the following SELECT is passed by the driver on to the database server, so it has nothing to do with QlikView, to the extent that the driver may not understand the statement even when it works in the query analyzer as it happens in your case, but the query is neither interpreted nor executed by QlikView.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But whay it might be happening is that the returning set has more than one field named alike, and since this is not allowed in QlikView, hence the error. That's why I strongly recommed to always use the LOAD part, so you are in full control on what you pull from the database and put into memory, renaming when necessary. If this is what is happening, though, you will need to rename in the SELECT statement, so all fields come with different names when loaded into QlikView.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say for example that your working query in SQL but not in QlikView is (names are fake)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 dbname.dbo.view1.common_col, dbname.dbo.view1.ID, dbname.dbo.view2.ID from dbname.dbo.view1&lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2&lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have two ID fields when it comes to QlikView loading, so you will need to rename at least one of them&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 dbname.dbo.view1.common_col, dbname.dbo.view1.ID, dbname.dbo.view2.ID AS ID2 from dbname.dbo.view1&lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2&lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the final script looks like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;TableName:&lt;/P&gt;&lt;P&gt;LOAD common_col,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID2;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 dbname.dbo.view1.common_col, dbname.dbo.view1.ID, dbname.dbo.view2.ID AS ID2 from dbname.dbo.view1&lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2&lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/people/mabaeyens" style="font-size: 12px; outline-style: none; padding-top: 1px; padding-bottom: 1px; padding-left: 17px; color: #007fc0; zoom: 1; background-position: no-repeat no-repeat;"&gt;Miguel Angel Baeyens&lt;/A&gt;&lt;/P&gt;&lt;P&gt;BI Consultant&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.grupocomex.com/" style="font-size: 12px; outline-style: none; color: #007fc0;"&gt;Comex Grupo Ibérica&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Aug 2011 11:45:37 GMT</pubDate>
    <dc:creator>Miguel_Angel_Baeyens</dc:creator>
    <dc:date>2011-08-30T11:45:37Z</dc:date>
    <item>
      <title>Sql Server Join Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309571#M709119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, I have been using QlikView and reading from flatfiles successfully, but I now have a requirement to read from a SQL Server database for my application. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I managed to connect to the db without any issues, but I am just trying to take my SQL Server code and paste it in QlikView as follows: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 * from dbname.dbo.view1 &lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2 &lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QlikView keeps throwing up an error on the join, but I know the join is correct, because it works perfectly in SQL Server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also noticed as well that QlikView did not like the alias names I used for the tables which were working fine in SQL Server so I took them out. I am pretty sure I am missing something very obvious and would appreciate it if someone can tell me where I am going wrong so i can proceed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 11:19:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309571#M709119</guid>
      <dc:creator />
      <dc:date>2011-08-30T11:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sql Server Join Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309572#M709121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that when you use SQL the following SELECT is passed by the driver on to the database server, so it has nothing to do with QlikView, to the extent that the driver may not understand the statement even when it works in the query analyzer as it happens in your case, but the query is neither interpreted nor executed by QlikView.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But whay it might be happening is that the returning set has more than one field named alike, and since this is not allowed in QlikView, hence the error. That's why I strongly recommed to always use the LOAD part, so you are in full control on what you pull from the database and put into memory, renaming when necessary. If this is what is happening, though, you will need to rename in the SELECT statement, so all fields come with different names when loaded into QlikView.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say for example that your working query in SQL but not in QlikView is (names are fake)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 dbname.dbo.view1.common_col, dbname.dbo.view1.ID, dbname.dbo.view2.ID from dbname.dbo.view1&lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2&lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have two ID fields when it comes to QlikView loading, so you will need to rename at least one of them&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 dbname.dbo.view1.common_col, dbname.dbo.view1.ID, dbname.dbo.view2.ID AS ID2 from dbname.dbo.view1&lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2&lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the final script looks like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;TableName:&lt;/P&gt;&lt;P&gt;LOAD common_col,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID2;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;top 200 dbname.dbo.view1.common_col, dbname.dbo.view1.ID, dbname.dbo.view2.ID AS ID2 from dbname.dbo.view1&lt;/P&gt;&lt;P&gt;inner join dbname.dbo.view2&lt;/P&gt;&lt;P&gt;on dbname.dbo.view1.common_col = dbname.dbo.view2.common_col&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/people/mabaeyens" style="font-size: 12px; outline-style: none; padding-top: 1px; padding-bottom: 1px; padding-left: 17px; color: #007fc0; zoom: 1; background-position: no-repeat no-repeat;"&gt;Miguel Angel Baeyens&lt;/A&gt;&lt;/P&gt;&lt;P&gt;BI Consultant&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.grupocomex.com/" style="font-size: 12px; outline-style: none; color: #007fc0;"&gt;Comex Grupo Ibérica&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 11:45:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309572#M709121</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-08-30T11:45:37Z</dc:date>
    </item>
    <item>
      <title>Sql Server Join Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309573#M709123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Miguel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your correct answer has led to another question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some fields, when I put them in the Load part so I can control the select statement, they error saying field not found, but the fields actually exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just wondering if you have come across that also and know a way to handle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 12:52:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309573#M709123</guid>
      <dc:creator />
      <dc:date>2011-08-30T12:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sql Server Join Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309574#M709124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's not unsual either. Check that fields are spelled exactly as they are in the database, not in the SQL SELECT statement. QlikView is case sensitive for both field names and values. Assuming all fields in the database are uppercase, the following will work in both QlikView and your query analyzer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SQL SELECT id, name, address&lt;/P&gt;&lt;P&gt;FROM database.table;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the correct LOAD statement will look like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Customer:&lt;/P&gt;&lt;P&gt;LOAD ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDRESS;&lt;/P&gt;&lt;P&gt;SQL SELECT id, name, address&lt;/P&gt;&lt;P&gt;FROM database.table;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the driver returns the fields uppercase even when you wrote them lowercase, then QlikView will read them uppercase. So if in the example you spell instead&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Customer:&lt;/P&gt;&lt;P&gt;LOAD ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name, // this will fail, this field doesn't exist because "name" &amp;lt;&amp;gt; "NAME"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADDRESS;&lt;/P&gt;&lt;P&gt;SQL SELECT id, name, address&lt;/P&gt;&lt;P&gt;FROM database.table;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/people/mabaeyens" style="font-size: 12px; outline-style: none; padding-top: 1px; padding-bottom: 1px; padding-left: 17px; color: #007fc0; zoom: 1; background-position: no-repeat no-repeat;"&gt;Miguel Angel Baeyens&lt;/A&gt;&lt;/P&gt;&lt;P&gt;BI Consultant&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.grupocomex.com/" style="font-size: 12px; outline-style: none; color: #007fc0; text-decoration: underline;"&gt;Comex Grupo Ibérica&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 17:44:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sql-Server-Join-Problem/m-p/309574#M709124</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-08-30T17:44:30Z</dc:date>
    </item>
  </channel>
</rss>

