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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

load data from all tables of a database

HEllo

I need to load data from all tables in a database

how can I loop through all tables to load the data in each single table in my script?

I can walk on water when it freezes
7 Replies
its_anandrjs
Champion III
Champion III

Hi,

Which type of tables it is means Excel,Sql or some other.

Rgds

Anand

ali_hijazi
Partner - Master II
Partner - Master II
Author

sql server

I can walk on water when it freezes
its_anandrjs
Champion III
Champion III

Hi,

Use

for each File in filelist ()

Sql Load statement


next File

HTH

Rgds

Anand

gandalfgray
Specialist II
Specialist II

Hi Anand

Have you tried using filelist to get tables from a sqlserver database?

Does that work?

According to the documentation:

The filelist mask syntax produces a comma separated list of all files in the

current directory matching the filename mask.

Ali,

I would suggest you to do something like:

LOAD "TABLE_CATALOG",

    "TABLE_SCHEMA",

    "TABLE_NAME",

    "TABLE_TYPE";

SQL SELECT *

FROM master."INFORMATION_SCHEMA".TABLES;

Then you would have all tables in the TABLES table.

and could create a loop where you get each tablename into a variable using the peek function

and use that variable in a generic SQL Select statement.

hth

/gg

Not applicable

This is my solution:

Tabelle:

SQLTABLES;

LET NTables = NoOfRows('Tabelle');

for i= 1 to NTables

  LET Tabella = FieldValue('TABLE_NAME', i );

  '$(Tabella)':
  SQL SELECT * FROM DB.$(Tabella);

NEXT i

matt_crowther
Specialist
Specialist

Not exactly the solution requested but I've created a Qlikview utility that does the requested and more.

It's a .qvw that first loads the sys.objects and sys.columns tables from a SQL datasource (even if the catalogue is hardened) presenting you with a front end where you select which table / views you wish to extract; make your selections hit reload and it extracts each selected table (or view) and stores it to QVD. (You can then use a simple '*' load from the QVD directory to load all teh tables into a new .qvw.)

This was designed for 2 reasons; extract data from SQL sources quickly and easily for off-site dev (really useful if you're in pre-sales) and secondly to allow the use of the columns field to quickly find source fields with a database - it gives you an isstant overview of the source db.

It should be straight forward to use, it's tested with SQL Server 2005+ and requires Excel 2003 or higher.

The password for the hidden script is 1234.

Hope it's of use.

Alt' Best,

Matt - Visual Analytics Ltd

Not applicable

Nice but this is only for SQL datasource, try SqlTables and SqlColumns commands.