Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

rustyfishbones
Honored Contributor 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
stevenrtaylor
Contributor II

Re: SQL SELECT Concat issue

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.

11 Replies

Re: SQL SELECT Concat issue

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

flipside
Valued Contributor II

Re: SQL SELECT Concat issue

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

stevenrtaylor
Contributor II

Re: SQL SELECT Concat issue

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
Honored Contributor II

Re: SQL SELECT Concat issue

Yes I am sure

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

rustyfishbones
Honored Contributor II

Re: SQL SELECT Concat issue

Hi Steve,

I tried that but no luck I'm afraid

rustyfishbones
Honored Contributor II

Re: SQL SELECT Concat issue

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

stevenrtaylor
Contributor II

Re: SQL SELECT Concat issue

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.

Re: SQL SELECT Concat issue

... 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
Valued Contributor II

Re: SQL SELECT Concat issue

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

flipside

EDIT: As Alessandro says !

Community Browser