Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
coco
Contributor II
Contributor II

A record is different between sql server and qlik sense

Read the code column from the database, and the record displayed as 0134 in the database (as shown in pic1) becomes 00134 in qlik sense(as shown in pic2) . Why? I'm sure this is the same record and the customer name is same.

Here is my coding,where should be modified?

LOAD *;

SQL

with t1 as(

select head.cwdzcode as code

from CP_kehu as head)

select code 

from  t1;

pic1.pngpic 2.png

 

5 Replies
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi, Not sure why this is happening.

My question is whether you want to remove those leading zeros or want to keep them as it is. 

Vegar
MVP
MVP

You could handle the field as a string/text. To do so you need to load the field using text() from the database, like this.

LOAD 
  text(code) as code, 
  zhongwenmingcheng,
  etc...
;
SQL
with t1 as(
select head.cwdzcode as code
from CP_kehu as head)
select code 
from  t1;

 

If you know that your code always is four (4) digits long then you also could use num() to format it like this.

LOAD 
  num(code,'0000') as code, 
  zhongwenmingcheng,
  etc...
;
SQL
with t1 as(
select head.cwdzcode as code
from CP_kehu as head)
select code 
from  t1;
coco
Contributor II
Contributor II
Author

I hope the data in qlik should be consistent with the database, so it should be 0134 in qlik, not 00134. So do you know what the problem is? How to make the record in qlik 0134?

coco
Contributor II
Contributor II
Author

Thank you very much!😃 I have got it.

Do you know how to  convert a string to nvarchar type in qlik?

Because I always encounter the problem that Chinese cannot be displayed in qlik, I need to convert the Chinese string to nvarchar(300) type first.I only know how to convert Chinese strings to nvarchar types in the database like this CAST('你好'  as nvarchar(300)) .How to implement in qlik?

PrashantSangle

if you are loading only one field from table then why you are using with (CTE)

Just use below query

SQL select cwdzcode as code
from CP_kehu;

 

answer to your 2nd question is you can same query which work in sql editor.

Qlik don't have have datatypes.

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂