Snowflake snippets

How to get information and the results of the last executed query

Let’s say you already executed the following simple query

SELECT 
    'John' AS Name, 
    DATE_TRUNC(month, CURRENT_DATE()) AS first_day_of_current_month;
 
Snowflake snippet 34

And you accidentally closed the results page.

To get the information about the last executed query you can just use the following

DESCRIBE RESULT LAST_QUERY_ID();
Snowflake snippet 35

While, if you want to also retrieve the results of the executed query, you can execute the following

SELECT *
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));
Snowflake snippet 36

Snowflake snippet 37

Back to Snowflake cookbook page