I am writing a stored procedure using Snowflake Scripting in which I need to copy out a Snowflake table into a .csv file, and add a timestamp to the file name. This table will have been created earlier in the procedure and will be saved with a variable name. I have two questions:
(1) How can I use the table variable name in the from statement of my copy command?
(2) How can I save the .csv file name with today's date stamp?
Below is how I would run this copy command in Snowflake SQL, where my_table is the name of the table I would like to copy out, and the file name is hard-coded rather than a variable.
copy into @my_stage/my_file_03072022.csv
from table($my_table)
file_format=(type=csv compression=none skip_header=1
field_optionally_enclosed_by= '"')
header = true
single = true
max_file_size = 4900000000
;
Thank you for your help!