<?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 SQL Load from Database incorrect data - Appending leading zero in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1567685#M441843</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've hit a big problem that I can't figure out.&lt;/P&gt;&lt;P&gt;I have a table that I am doing an SQL Query on. Really, really simple.&lt;/P&gt;&lt;P&gt;The script I am using is:&lt;/P&gt;&lt;PRE&gt;TempItem:
SQL SELECT 
"Item-no",
"Full-Description"
FROM UKTABLE.PUB."item";&lt;/PRE&gt;&lt;P&gt;The field I am interested in is the "Item-no", this contains some item numbers with leading zero's and some without.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;PRE&gt;Item-No   |   Full-Description&lt;BR /&gt;-------------------------------------------------------
38033     |   Part 1
038033    |   Sub-Assembly 1&lt;/PRE&gt;&lt;P&gt;As you can see there are two part numbers.&lt;/P&gt;&lt;P&gt;But when I run the above code and put the fields in a table, I get the following:&lt;/P&gt;&lt;PRE&gt;Item-No | Full-Description&lt;BR /&gt;------------------------------------------------------- &lt;BR /&gt;038033  | Part 1 &lt;BR /&gt;038033  | Sub-Assembly 1&lt;/PRE&gt;&lt;P&gt;*Note that Part 1 now has a zero at the front.&lt;/P&gt;&lt;P&gt;This is incorrect and is skewing my figures.&lt;/P&gt;&lt;P&gt;I know that QV stores the value as double, but I've tried this too with no success:&lt;/P&gt;&lt;PRE&gt;TempItem: 
SQL &lt;BR /&gt;SELECT CAST("Item-no" as varchar(20)) AS "Item-no", &lt;BR /&gt;"Full-Description" &lt;BR /&gt;FROM UKTABLE.PUB."item";&lt;/PRE&gt;&lt;P&gt;And I've also saved the data to a .qvd and loaded it with the following, again with no success:&lt;/P&gt;&lt;PRE&gt;TempItem:
LOAD text([Item-no]) as [Item-no], 
Full-Description
FROM
[D:\Qlikview\UK\Data\Item.qvd](qvd);&lt;/PRE&gt;&lt;P&gt;Here is my SQL Database table, as you can see it's already in text format&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 300px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/9896i88C20481658D9354/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Has anyone come across this before?&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 03:53:59 GMT</pubDate>
    <dc:creator>chris1987</dc:creator>
    <dc:date>2024-11-16T03:53:59Z</dc:date>
    <item>
      <title>SQL Load from Database incorrect data - Appending leading zero</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1567685#M441843</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've hit a big problem that I can't figure out.&lt;/P&gt;&lt;P&gt;I have a table that I am doing an SQL Query on. Really, really simple.&lt;/P&gt;&lt;P&gt;The script I am using is:&lt;/P&gt;&lt;PRE&gt;TempItem:
SQL SELECT 
"Item-no",
"Full-Description"
FROM UKTABLE.PUB."item";&lt;/PRE&gt;&lt;P&gt;The field I am interested in is the "Item-no", this contains some item numbers with leading zero's and some without.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;PRE&gt;Item-No   |   Full-Description&lt;BR /&gt;-------------------------------------------------------
38033     |   Part 1
038033    |   Sub-Assembly 1&lt;/PRE&gt;&lt;P&gt;As you can see there are two part numbers.&lt;/P&gt;&lt;P&gt;But when I run the above code and put the fields in a table, I get the following:&lt;/P&gt;&lt;PRE&gt;Item-No | Full-Description&lt;BR /&gt;------------------------------------------------------- &lt;BR /&gt;038033  | Part 1 &lt;BR /&gt;038033  | Sub-Assembly 1&lt;/PRE&gt;&lt;P&gt;*Note that Part 1 now has a zero at the front.&lt;/P&gt;&lt;P&gt;This is incorrect and is skewing my figures.&lt;/P&gt;&lt;P&gt;I know that QV stores the value as double, but I've tried this too with no success:&lt;/P&gt;&lt;PRE&gt;TempItem: 
SQL &lt;BR /&gt;SELECT CAST("Item-no" as varchar(20)) AS "Item-no", &lt;BR /&gt;"Full-Description" &lt;BR /&gt;FROM UKTABLE.PUB."item";&lt;/PRE&gt;&lt;P&gt;And I've also saved the data to a .qvd and loaded it with the following, again with no success:&lt;/P&gt;&lt;PRE&gt;TempItem:
LOAD text([Item-no]) as [Item-no], 
Full-Description
FROM
[D:\Qlikview\UK\Data\Item.qvd](qvd);&lt;/PRE&gt;&lt;P&gt;Here is my SQL Database table, as you can see it's already in text format&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 300px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/9896i88C20481658D9354/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Has anyone come across this before?&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:53:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1567685#M441843</guid>
      <dc:creator>chris1987</dc:creator>
      <dc:date>2024-11-16T03:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Load from Database incorrect data - Appending leading zero</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1567736#M441848</link>
      <description>&lt;P&gt;Try it in this way:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TempItem:&lt;BR /&gt;load text(&lt;SPAN&gt;"Item-no") as &lt;SPAN&gt;"Item-no"&lt;/SPAN&gt;, "Full-Description";&lt;/SPAN&gt;&lt;BR /&gt;SQL SELECT "Item-no", "Full-Description"&lt;BR /&gt;FROM UKTABLE.PUB."item";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 14:43:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1567736#M441848</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-04-10T14:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Load from Database incorrect data - Appending leading zero</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1568020#M441868</link>
      <description>&lt;P&gt;Thanks Marcus,&lt;/P&gt;&lt;P&gt;I've only done a small sample test and it appears to be working! So just running it on the full db now.&lt;/P&gt;&lt;P&gt;Do you know why this works? Would be good if you could explain a little or point me in the direction of an answer. Will be good to know in future.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 08:32:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1568020#M441868</guid>
      <dc:creator>chris1987</dc:creator>
      <dc:date>2019-04-11T08:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Load from Database incorrect data - Appending leading zero</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1568039#M441870</link>
      <description>&lt;P&gt;The reason for this behaviour is that Qlik doesn't really know data-types else it interprets the data as numeric or strings - and this happens by the first loaded field-value and is then applied to the whole column. With the most of the columns it worked very smoothly and only by such cases with a leading zero or similar stuff you need to enforce a different handling which is usually done with a text().&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 09:00:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-Load-from-Database-incorrect-data-Appending-leading-zero/m-p/1568039#M441870</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-04-11T09:00:47Z</dc:date>
    </item>
  </channel>
</rss>

