HELP: Script that calls a script??

HELP: Script that calls a script??

Post by Stephen J. Koni » Sat, 25 Apr 1998 04:00:00



Hello everyone.

This seems like a relatively simple thing to do, but for the life of me I
cannot figure out how to get this to work, or even if it is possible with
SQL Server (though it seems it ought to be).

What I would like to do is create one .SQL script file that I can load into
ISQL or ISQL/W that will iteratively call several other .SQL script files.
Specifically, we have script files to create all of the tables for our
schema -- I would like to create a 'master' creation script that calls each
of these individual ones.  The idea here is that this way when doing a
clean installation the administrator only has to load one script file and
execute it.

In Oracle this is simple to do -- you just include a line in your script

and it will load and execute the script file indicated by <filename>.
Despite my best efforts at uncovering how this is to be done in SQL Server,
however, I can't seem to find any documentation that shows how this is
done!

I've thought about writing a script that calls xp_cmdshell with ISQL for
each of the script file, but of course I cannot seem to think of a way to
pass in the password as a command-line argument without first prompting the
user to type it in.  Plus, this seems like a hokie way to implement such a
simple requirement.

Can anyone point me in the right direction here?  Any help would be most
appreciated!  Thanks in advance.

Stephen K.
--
+----------------------------------------------------------
| Stephen J. Konig
| Software Engineer
| Meridium Inc.
| Roanoke, Va.
|
| http://www.meridium.com

+----------------------------------------------------------

 
 
 

HELP: Script that calls a script??

Post by Babe » Sat, 25 Apr 1998 04:00:00


Create a cmd or bat file, say XXX.CMD that contains the following command
lines:

isql /U yourname /P your password /i inputfile1.qry >> errorlog.txt
isql /U yourname /P your password /i inputfile2.qry >> errorlog.txt
isql /U yourname /P your password /i inputfile3.qry >> errorlog.txt
.
.
.
isql /U yourname /P your password /i inputfilen.qry >> errorlog.txt

At a command line in the directory of your input files.sql, run XXX.

Good luck!
Kilong


>Hello everyone.

>This seems like a relatively simple thing to do, but for the life of me I
>cannot figure out how to get this to work, or even if it is possible with
>SQL Server (though it seems it ought to be).

>What I would like to do is create one .SQL script file that I can load into
>ISQL or ISQL/W that will iteratively call several other .SQL script files.
>Specifically, we have script files to create all of the tables for our
>schema -- I would like to create a 'master' creation script that calls each
>of these individual ones.  The idea here is that this way when doing a
>clean installation the administrator only has to load one script file and
>execute it.

>In Oracle this is simple to do -- you just include a line in your script
>file that reads:

>and it will load and execute the script file indicated by <filename>.
>Despite my best efforts at uncovering how this is to be done in SQL Server,
>however, I can't seem to find any documentation that shows how this is
>done!

>I've thought about writing a script that calls xp_cmdshell with ISQL for
>each of the script file, but of course I cannot seem to think of a way to
>pass in the password as a command-line argument without first prompting the
>user to type it in.  Plus, this seems like a hokie way to implement such a
>simple requirement.

>Can anyone point me in the right direction here?  Any help would be most
>appreciated!  Thanks in advance.

>Stephen K.
>--
>+----------------------------------------------------------
>| Stephen J. Konig
>| Software Engineer
>| Meridium Inc.
>| Roanoke, Va.
>|
>| http://www.meridium.com

>+----------------------------------------------------------


 
 
 

HELP: Script that calls a script??

Post by Andrew Prosse » Sat, 25 Apr 1998 04:00:00



>Create a cmd or bat file, say XXX.CMD that contains the following command
>lines:

>isql /U yourname /P your password /i inputfile1.qry >> errorlog.txt
>isql /U yourname /P your password /i inputfile2.qry >> errorlog.txt
>isql /U yourname /P your password /i inputfile3.qry >> errorlog.txt
>.
>.

If you user this you might want to consider the trusted connection option /E
or the following;

The isql ISQLPASSWORD environment variable allows you to set a default
password for the current session. Therefore, you do not have to hard code a
password into batch files.
If you do not specify a password with the /P qualifier, isql first checks
for the ISQLPASSWORD variable. If no value is set, isql uses the default
password, NULL. The following example sets the ISQLPASSWORD variable at the
command prompt and then accesses the isql utility:

C:\>SET ISQLPASSWORD=abracadabra
C:\> isql

You can read files into ISQl but you have to do it interactively;

When using isql interactively, you can read an operating-system file into
the command buffer with :r filename. Do not include a command terminator in
the file; enter the terminator interactively once you have finished editing.

Regards
--
Andrew Prosser