Pavan Koundinya Kaipa
Pavan Koundinya Kaipa

Reputation: 21

How to execute multiple temp tables within a single query at one go in DBVisualizer?

I joined a new company and they are using DBVisualizer. For the last 5 years, I used SQL Server and I am now appreciating SQL Server for its intelligent execution of queries.

One of the problems I am facing is executing multiple temp tables at a time. For example, trying to execute the following throws me an error saying #abc is not available. This was not a problem in SQL Server as it used to execute it smartly.

drop table if exists #abc;
create table #abc as
select a.ID, a.EMP
from sandbox.table1 as a

drop table if exists #cde;
create table #cde as
select a2.ID, sum(a1.sum) as Rev
from sandbox.table2 as a1
join #abc as a2 on a1.ID = a2.ID
group by a2.ID

Upvotes: 1

Views: 1062

Answers (2)

Pearl
Pearl

Reputation: 1

I had same issue and found very vey easy solution. click anywhere in each sql statement first word (drop, select etc.) and hit CTRL + Enter. Do that for each query in same sequence as it is in entire sql query. All queries will run without error.

Upvotes: 0

conol
conol

Reputation: 425

if you are looking to use certain queries as a table on runtime try WITH it will help you create a temporary view at runtime for a perticular query. then you can use this query output as a table and use it.

Example -

with userTBL as ( 
  select * 
  from user  
  where activated=true
),
usertiming as (
  select date,userID
  from timingtabls
  where date=currentdate
) 
select * from userTBL left join timing t on t.userID=id;

Upvotes: 2

Related Questions