Reputation:
We have a query in Big Query like below
CREATE temp table ttt as (
SELECT * FROM TABLE
);
EXECUTE IMMEDIATE (
---Dynamic query goes here---
);
The above query is storing the results in a temporary table as written in the query. How to store these results into an actual table/view so that it can be utilized for further data modelling?
Upvotes: 0
Views: 4584
Reputation: 173190
As I already suggested you in your previous question - just add CREATE TABLE your_table AS
or INSERT your_table
as in below example. Use CREATE (DDL) or INSERT (DML) depends on do you need to create new table or insert into existing one
EXECUTE IMMEDIATE (
CREATE TABLE dataset.table AS
SELECT ---Rest of your dynamic query goes here---
);
Upvotes: 0
Reputation: 314
Try to use:
EXECUTE IMMEDIATE (concat('create table dataset.table as ',---Dynamic query goes here---)
);
Upvotes: 1
Reputation: 5518
Could you use a persistent table in the first place? Or could you save the results after EXECUTE IMMEDIATE
using query below?
CREATE TABLE yourDataset.ttt as (
SELECT * FROM ttt
);
Upvotes: 0