Skip to content
Advertisement

Snowflake Scripting in SQL – how to iterate over the results of a SHOW command?

I’m checking out the new SQL Snowflake Scripting (in preview), and I can’t figure out how to iterate over the results of a SHOW command — especially as some columns are lower cased.

Advertisement

Answer

You can use this example as a template to iterate over results of SHOW:

First, note that you can get the resultset from show in the declare part – that makes life easy.

Then you can have a cursor to go over each row with for vw in vw_cursor do.

Then you can execute immediate other queries, but make sure to quote with " to get the lower-cased columns like in vw."name".

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