0

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!

patel94
  • 85
  • 2
  • 11

2 Answers2

1

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.

Mike Gohl
  • 627
  • 4
  • 7
  • That is possible but I want to run like this. So, I can put as many files as I want and run just one .sql file. – patel94 May 18 '20 at 18:40
  • Please let me know if there is any way to do this. Thanks! – patel94 May 18 '20 at 19:14
  • I have tried using !source. But the problem is with multiple .sql files. I dont know how to define multiple .sql files inside my test.sql file. Do I need to call something like this in my file: !source file1.sql; !source file2.sql; !source file3.sql; Let me know if this possible? – patel94 May 18 '20 at 20:31
1

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.

patel94
  • 85
  • 2
  • 11