Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
boorgura
Valued Contributor

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

Delete all resident tables

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

7 Replies
vgutkovsky
Honored Contributor II

Delete all resident tables

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

Not applicable

Delete all resident tables

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

MVP
MVP

Delete all resident tables

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

Delete all resident tables

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

Delete all resident tables

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

Delete all resident tables

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

Not applicable

Re: Delete all resident tables

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