Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
satishqlik
Creator II
Creator II

Load tables

Hi All,

I've been trying to load all tables from database

and creating QVDs automatically but not working properly.

If I add [] its getting an error and It working be fine if the table name has no spaces.

Suggest me on this where am wrong.

Tablelist:

LOAD*

Inline

[Tablename

Categories

Customers

Divisions

Order Details

Products

Shippers

Shipments

];

FOR i=1 to FieldValueCount('Tablename')

LET Vtable= FieldValue('Tablename',i);

SQL SELECT *

FROM [$(Vtable)];

SET VQvdPath= D:\Practice\Data\QVDS\;

STORE [$(Vtable)] into $(VQvdPath)[$(Vtable)].qvd(qvd);

NEXT

Any suggestions will be appreciated.

17 Replies
maxgro
MVP
MVP

this works in my test

SET VQvdPath= D:\Practice\Data\QVDS\;

FOR i=1 to FieldValueCount('Tablename')

    LET Vtable = FieldValue('Tablename', $(i));

    //trace $(Vtable);

    [$(Vtable)]:

    NoConcatenate LOAD *;

    SQL SELECT *  FROM [$(Vtable)];

   

    STORE [$(Vtable)] into [$(VQvdPath)$(Vtable).qvd] (qvd);

NEXT

satishqlik
Creator II
Creator II
Author

Sorry for my late response!

Finally I got all the tables in the data model along with Order Details( Syn table) table But why QVDs were not generated?Any Idea?

share3.png

sunny_talwar

Same table name? Not sure I understand your question. Would you be able to elaborate?

satishqlik
Creator II
Creator II
Author

Sunny there were no QVDs in the mentioned QvdPath it is an empty..Why it is?

sunny_talwar

Can you try this:

FOR i=1 to FieldValueCount('Tablename')

    LET Vtable = '[' & FieldValue('Tablename', $(i)) & ']';

  $(Vtable):

    SQL SELECT *

    FROM $(Vtable);

    SET VQvdPath= D:\Practice\Data\QVDS\;

    STORE $(Vtable) into $(VQvdPath)$(Vtable).qvd(qvd);

NEXT

or

FOR i=1 to FieldValueCount('Tablename')

    LET Vtable = '[' & FieldValue('Tablename', $(i)) & ']';

    LET VtableStore = FieldValue('Tablename', $(i));

    $(Vtable):

    SQL SELECT *

    FROM $(Vtable);

    SET VQvdPath= D:\Practice\Data\QVDS\;

    STORE $(Vtable) into $(VQvdPath)$(VtableStore).qvd(qvd);

NEXT

satishqlik
Creator II
Creator II
Author

Thanks maxgro its working great.

But am unable to understand your expression in that why did you use NOConcatenate keyword.?

If you don't mind,Would you be able to elaborate little bit more?


Thannks Again!

satishqlik
Creator II
Creator II
Author

Thanks Sunny for your effort now your expression is working great!!!

maxgro
MVP
MVP

May be you have 2 source tables with the same names and number of fields. Qlik will concatenate the tables and I don't want this. So I add a noconcatenate. Another way is to add a drop table after the store.