I am very new to Snowflake. I need to retrieve only the column names of a table and then return it as an array in a stored procedure.
Example:
Column_A Column_B Column_C Column_D
1 2 2 2
should return [ Column_A, Column_B, Column_C, Column_D]
Here is my attempt:
create or replace procedure sample()
return RETURNTYPE?
language javascript
AS
$$
var cmd = 'SELECT COLUMN_NAME' FROM table1;
var statement = snowflake.createStatement({sqlTest: cmd});
var res = statement.execute();
var arr = [];
//HOW CAN I PUSH COLUMN NAMES INTO THIS ARRAY
return ARRAY;
$$;
I new to this. Can someone explain how to solve this.