patel94
patel94

Reputation: 125

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!

Upvotes: 1

Views: 4106

Answers (2)

patel94
patel94

Reputation: 125

I have tried defining .sql file with !source inside my test.sql file and its working:

!source file1.sql;
!source file2.sql;
!source file3.sql;

....

Also, run the same command in power shell using one .sql file and it is working.

Upvotes: 4

Mike Gohl
Mike Gohl

Reputation: 737

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.

Upvotes: 3

Related Questions