Search code examples
sqlsnowflake-cloud-data-platformsnowsql

How can I run .sql file having multiple .sql file inside using Snowsql?


I want to figure out how to run multiple sql files on one go. Suppose I have this test.sql file which has file1.sql, file2.sql and file3.sql and so on. Along with some DML/DDL.

use database &{db};
use schema &{sc};

file1.sql;
file2.sql;
file3.sql;

create table snow_test1
(
name varchar
,add1 varchar
,id number
)
comment = 'this is snowsql testing table' ;

desc table snow_test1;

insert into snow_test1 
values('prachi', 'testing', 1);

select * from snow_test1; 

here what I run in power shell,

snowsql -c pp_conn -f ...\test.sql -D  db=tbc -D  sc=testing;

Is there any way to do this ? I know It is possible in Oracle but I want to do this using snowsql. Please guide me. Thanks in advance!


Solution

  • you can run multiple files in a single call:

    snowsql -c pp_conn -f file1.sql -f file2.sql -f file3.sql -D  db=tbc -D  sc=testing;
    

    You might need to put the addition DMLs in a file.