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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
neerajthakur
Creator III
Creator III

Finding table records and fields while extracting table from DB

I want to know no. of records and field names  in each table extracted before storing and dropping them or even put tables with 0 records into a new folder.

As there are many table in DB and many are blank it becomes hard doing it manually. I want no. of records and field names as it makes discussion easier as sometimes client is still developing and creates table for future.

ListofTable:
SELECT
TABLE_NAME AS TableName,
Table_schema
from information_schema.tables where table_schema='school';

for i=0 to NoOfRows ('ListofTable')-1

let vTableName=Peek('TableName',$(i),'ListofTable');

$(vTableName):
SQL SELECT * from
school.$(vTableName);


Store $(vTableName) Into [lib://Extraction/School/$(vTableName).qvd] (qvd);

Drop Table $(vTableName);
//
next

Exit Script;

Thanks & Regards,
Please Accepts as Solution if it solves your query.
Labels (3)
1 Reply
marcus_sommer
MVP
MVP

Like you pull the existing tables from the database system-tables you could also read the number of records and fields from there. Personally, I wouldn't be surprised if this information is within the same schema-table. The help and/or the community from your database should provide all needed details - whereby a:

Select * from information_schema.tables;

will return all fields from the table and a quick check with a tablebox on this data will help to find the needed information - and with it you could extend the where-clause.

- Marcus