Below is the example.
BEGIN
set tablenameA = 'tablenamelala';
SELECT * FROM table($tablenameA);
END
I am expecting it will return me the result from the select statement.
Below is the example.
BEGIN
set tablenameA = 'tablenamelala';
SELECT * FROM table($tablenameA);
END
I am expecting it will return me the result from the select statement.
2
Answers
as per your requirement you can use the UDTF. which will return the table content as result.
https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-tabular-functions.html
Variables work a little differently in an anonymous block. The code below will only work "as-is" in the Snowsight web-UI. Otherwise, it needs to be enclosed with double dollar signs.
Snowsight:
All Other clients:
if this is something repeated you can use a stored procedure.