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.
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.
- Generate Script of SQL Server Objects – SQL in Sixty Seconds #184
- Prevent Unauthorized Index Modifications – SQL in Sixty Seconds #183
- MAX Columns Ever Existed in Table – SQL in Sixty Seconds #182
- Tuning Query Cost 100% – SQL in Sixty Seconds #181
- Queries Using Specific Index – SQL in Sixty Seconds #180
- Read Only Tables – Is it Possible? – SQL in Sixty Seconds #179
- One Scan for 3 Count Sum – SQL in Sixty Seconds #178
- SUM(1) vs COUNT(1) Performance Battle – SQL in Sixty Seconds #177
- COUNT(*) and COUNT(1): Performance Battle – SQL in Sixty Seconds #176
Reference:Â Pinal Dave (http://blog.SQLAuthority.com)