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: 
boorgura
Specialist
Specialist

Delete all resident tables

Hi Qlik-ers,

This might sound a bit wierd. I am looking to drop all tables from the file.

I thought "drop table *;" should do it. but it doesn't.

Can anyone please let me know if there is quick to do this?

Any help will be appreciated.

Thanks,

Rocky

1 Solution

Accepted Solutions
vgutkovsky
Master II
Master II

Yep, here you go:


let numTables = NoOfTables();
for i=1 to $(numTables)
let tt = TableName(0);
drop table [$(tt)];
next


Regards,

View solution in original post

8 Replies
vgutkovsky
Master II
Master II

Yep, here you go:


let numTables = NoOfTables();
for i=1 to $(numTables)
let tt = TableName(0);
drop table [$(tt)];
next


Regards,

Not applicable

Hi,

try the script below.

LET vAnz=NoOfTables();
FOR i=1 to vAnz
LET vTab=TableName(0);
DROP TABLE $(vTab);
NEXT i

If thats works, please verify and reply, if not please also give me feedback so we could solve your issue.

Best regards

Michael

johnw
Champion III
Champion III

There must be a way to do it with a loop through all tables, but I'm not sure exactly how to set it up.

Edit: Whoops. Two people posted solutions while I was trying to figure it out. Never mind!

boorgura
Specialist
Specialist
Author

Vlad and Michael,

Thanks for your time. you both are almost on the same lines.

and yes both of your scripts do work.

Actually I already had something similar to that... was looking if we had a direct way to do this.

Anyways... Thanks again...

- Rocky

Not applicable

In the following :

let numTables = NoOfTables();

for i=1 to $(numTables)

let tt = TableName(0);

drop table [$(tt)];

next

NoOfTables() returns 0 when a qlikview document is opened only and not reloaded.

Is there a way to get the actual number of tables in qlikview document when it is just opened and not reloaded and open.

vgutkovsky
Master II
Master II

You mean it's open without data? What are you trying to accomplish?

Not applicable

Just to add to the topic:

If you need to retain any Tables  you can use following code

//Don't use ','  it will confuse index function. I used a space as a seperator

SET vexemptList='Table1   Table2   Table3 ';

LET vNoofTables = NoOfTables();

For vTableNo = 0 to vNoofTables-1 ;

  //When one table get deleted the next in line get that number.So always delete first table in the list.

  //For example if there is 4 tables and loop already finished 2 times there will not be any value for TableName(3)

  vTableName = TableName(0) ;

  Let vIndex = Index('$(vexemptList)','$(vTableName)') ;

  If $(vIndex)=0  then

  DROP Table $(vTableName);

  ENDIF

NEXT

Amit_Kakkad_PD
Contributor II
Contributor II

Simple and perfect! Thanks!