Snowflake – Stored Procedure Template in JavaScript

In the real world, I often get to work on multiple technologies. Every time, I work with my clients on Comprehensive Database Performance Health Check, along with SQL, I often get to work on different technologies. Recently, I got the opportunity to work on Snowflake. One of the most interesting things about Snowflake is that it has stored procedures written in Javascript. Yes, you can write your SP in JS only. While, I know JavaScript very well, many SQL developers do not know it well. For everyone to use, I am going to share the Stored Procedure Template in JavaScript for Snowflake.

Snowflake - Stored Procedure Template in JavaScript ProcedureTemplate-800x155

Stored Procedure Template

I always use the following template to execute my SP in Snowflake.

CREATE OR REPLACE PROCEDURE SampleStoredProcedure()
returns string not null
language javascript
as
$$
var cmd = 'SELECT 1'
var sql = snowflake.createStatement({sqlText: cmd});
var result = sql.execute();
return 'Success';
$$;

You can call the SP using the following command.

CALL SampleStoredProcedure();

Let me know if you would like to learn more about Snowflake. I will be happy to share my tutorial on this topic.

Here are my few recent videos and I would like to know what is your feedback about them. Do not forget to subscribe SQL in Sixty Seconds series. I hope you appreciate learning about the Last 5 SQL in Sixty Seconds Video.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

, , ,
Previous Post
SQL SERVER Agent Missing from SSMS
Next Post
Snowflake – Query Result from Cache or Disk

Related Posts

Leave a Reply

Menu