Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
rustyfishbones
Master II
Master II

SQL SELECT Concat issue

Hi All,

I have the following piece of code for extracting from the DB and it works ok

CAST.png

However it does not concat the "trx-no" within the string and I get no error message

Any idea why I can't join the trx-no to the rest of the string?

Regards

Alan

1 Solution

Accepted Solutions
Anonymous
Not applicable

Try casting it as a varchar instead of char and supply an argument that is matches the max expected length of the field.

even if you use varchar(20) and it only takes up 3 digits, it will drop the extras. I think it may be the lack of length argument that is causing your problems.

View solution in original post

11 Replies
alexandros17
Partner - Champion III
Partner - Champion III

are you sure that trx-no is not null or empty?

flipside
Partner - Specialist II
Partner - Specialist II

I was about to suggest bringing throught that field (with CAST statement) on its own to see if indeed that was the situation.

Anonymous
Not applicable

Try replacing the double quotes in your SQL statement with open and close square brackets. The SQL engine could be interpreting your double quotes as string values rather than column names.

Also, try copying and pasting everything after the SQL keyword into SQL Server Management Studio and running directly against the DB. Better error feedback that way.

rustyfishbones
Master II
Master II
Author

Yes I am sure

trx-no is always available, no nulls or empty data

rustyfishbones
Master II
Master II
Author

Hi Steve,

I tried that but no luck I'm afraid

rustyfishbones
Master II
Master II
Author

Hi flipside

trx-no loads no problem with all values, however when I change to

CAST("trx-no" AS CHAR) AS trx-no

All values are blank??

maybe I'll try CONVERT

Anonymous
Not applicable

Try casting it as a varchar instead of char and supply an argument that is matches the max expected length of the field.

even if you use varchar(20) and it only takes up 3 digits, it will drop the extras. I think it may be the lack of length argument that is causing your problems.

alexandros17
Partner - Champion III
Partner - Champion III

... what about your query if you adda anew column trx-no?

Is it visible?

There is anoher solution:

Do the same with Qlik so:

Load ..;

Select

..

flipside
Partner - Specialist II
Partner - Specialist II

Can you bring it through without the CAST and make the concatenation in a preceding load?

flipside

EDIT: As Alessandro says !