teu
teu

Reputation: 979

Parameterized path in "copy into" statement?

Is there a way to parameterize the path used by a copy into statement in Snowflake's SQL? I'd like to do something like, for example: copy into @temp_int_stage/test_$v from ..., where $v is a SQL variable.

Upvotes: 0

Views: 1111

Answers (3)

Sriga
Sriga

Reputation: 1321

If you are using any programming interface to load files from stage to final target table you can do it. We are using python script to load our data from snowflake stage to target table. Where in copy command file path will be parameterized.

Else, you can use in snowflake stored procedure. I'm not sure, is there any way to execute directly.

Upvotes: 1

PIG
PIG

Reputation: 602

you can define variable in snowsql. For that you have to enable variable substitution. Later you can use variable with & operator

!define val = yourvalue
!set variable_substitution=True
copy into @temp_int_stage/test_&val from ..

Upvotes: 1

Mike Walton
Mike Walton

Reputation: 7339

Best way to accomplish this is through a Snowflake Stored Procedure. You can't do it directly using a variable in the SQL Statement, though.

Upvotes: 1

Related Questions