Skip to content
Advertisement

How to reference variables in Snowflake SQL script

I’m writing a script to create 5 tables, but cannot seem to get the SQL DDL part of the statement to work. I get a syntax error " unexpected 'table' ", and I’ve tried the SQL statement with execute immediate as well. What am I doing wrong?

Advertisement

Answer

To quote the documentation:

If you are using the variable as the name of an object (e.g. the name of a table in the FROM clause of a SELECT statement), use the IDENTIFIER keyword to indicate that the variable represents an object identifier. For example:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement