Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
chriys1337
Contributor II

Drop all Tables except

Hi,

I am looking for a way to drop all existing tables in my datamodel, except some Tables which can be stated in the script.

I have found in the Community two solutions, which I tried and it definitely does not work for me.

(

Drop All Tables Except)

Anybody has a workable solution for this case?

Thx a lot,

Chris

1 Reply
graziella_seraf
New Contributor II

Re: Drop all Tables except

I Christian,

What is your issue with drop table statement?

I had a problem wit it too, but I resolved. My problem was that at the end of the script not all table were dropped.

After tests and retest, I undertood that, during dropping, the 'TableNumber' of existing table change!! So, if for example the number of "TableX" at the beginning is 15, during dropping can change in 10, 5,0...and when the n of your FOR is 15, the function "tablename(15)" is null.

Then I revolved using a different approach...not a cycle, but a long string.

FOR i = 0 to NoOfTables()-1

  TableList:

  LOAD TableName($(i)) as Tablename AUTOGENERATE 1

  WHERE not WildMatch(TableName($(i)), 'TableA','TableB','TableC');

NEXT i

TableList1:

load concat(Tablename, ',') as Tablename1

resident TableList;

let vdrop= peek('Tablename1');

DROP Tables TableList,TableList1;

DROP Tables $(vdrop);

I hope this can help you.