In this short post, we will demonstrate how you can use the cmd to run your recurrent queries.
SnowSQL is a command line client that you can run interactively as a shell, or you can run in batch mode. Commands can be referenced via a -f parameter (common on Windows) or redirected into it via stdin (common on Linux and macOS).
Using SnowSQL is very much like using OSQL or SQLCMD. Like SQLCMD though, it has a rich command language of its own with variables, auto-complete, command line history, and variable substitution.
First create a folder where you can put all your .sql files & one .bat file as the following :
The idea here is to prepare QA sql files for validation purposes, or other analytical queries, rather than executing them through the webapp or any other SQL client manually, you can do this way to automate that and save time.
In the Automated_QA.bat file , you can paste the following , please keep in mind, i’m connecting to snowflake through Okta ( federated SSO ):
:: This CMD script provides full QA execution
ECHO Start Testing …
ECHO Connecting to Snowflake …
del tempfile >nul 2>&1
for /F %%i in ('dir /b *.sql') do @echo| set /p output= -f %%i >> tempfile
set /p myvar= < tempfile del tempfile >nul 2>&1
SET a=snowsql --authenticator https://logon.okta.com/ -a XXX.eu-central-1 -d XXX -s XXX -w XXX -r XXX
SET b=-u firstname.lastname@example.org
SET c=%a% %b% %myvar%