Yes. Wait(0) actually does not do as you suggest. The queries actually return in a random order, based on (what appears to be) their size and complexity. I have 7 queries and it is the 4th one that takes a long time. I have tried to put that query first in the script, but the others run so fast that this one still has not completed when the remaining code in the script executes.
Here is part of the code I am using, with much of it removed to protect the source. But, it gives the general structure. I have removed queries 4-7 and the last 4 Join statements at the end for brevity.
Query1 = New SQL Query(
Connection( ...
),
Order By( ),
PostQueryScript( ...
)
);
Query1 << Run;
Wait(0);
Query2 = New SQL Query(
Connection( ...
),
Order By( ),
PostQueryScript( ...
)
);
Query2 << Run;
Wait(0);
Query3 = New SQL Query(
Connection( ...
),
Order By( ),
PostQueryScript( ...
)
);
Query3 << Run;
Wait(0);
//Join Tables
Table12 = Data Table( "01" ) << Join(
With( Data Table( "02" ) ),
Merge Same Name Columns,
Match Flag( 0 ),
By Matching Columns(
:
),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 ),
Output Table( "12" )
);
Table123 = Data Table( "12" ) << Join(
With( Data Table( "03" ) ),
Merge Same Name Columns,
Match Flag( 0 ),
By Matching Columns(
:
),
Drop multiples( 0, 0 ),
Include Nonmatches( 0, 0 ),
Preserve main table order( 1 ),
Output Table( "123" )
);