1
votes

I am trying to place my snowflakes into git repository. Some of the part are environment specific, like use schema analytics_dev ### I will have to change this while deploying to qa and stuff.

I was thinking if could replace these with variable like this

set env='dev' use schema analytics+$env

But this an error "SQL compilation error: syntax error line 1 at position 20 unexpected '+'." How do I achieve this functionality?

2

2 Answers

0
votes

Here's a way, to append vars, and use as an identifier:

set env = 'dev';
set analytics_schema = 'analytics' || $env;
use schema identifier($analytics_schema);
0
votes

A couple of options here:

set (min, max)=(40, 70);
select $min;

And this:

set var_artist_name ='Jackson Browne';
select getvariable('var_artist_name');

and more here: https://docs.snowflake.com/en/sql-reference/session-variables.html