SQL Batch Scripts

  • Thread starter Thread starter Jeff V via AccessMonster.com
  • Start date Start date
J

Jeff V via AccessMonster.com

Just wondering if there is a way of calling a sql script from another sql
script. I have a bunch of .sql files that build my database and I execute
these through a .bat file. I was wondering if this could be done with a .sql
file instead. The reason is that I would like to build the database in query
analyzer vs. command window.
 
uh you could write an extended sproc to do this

i thought that there was something already

but what are you doing through the command line; isql?

you can definitely call batch commands through SQL

exec xp_cmdshell 'c:\mybat.bat'

hth
 
you can definitely call batch commands through SQL

exec xp_cmdshell 'c:\mybat.bat'

Well, of course you can, but sa-privileges are required
to use xp_cmdshell which may be not available to the user.

Furthermore all the files that will be used by xp_cmdshell
have to accessible from the server and by the account
running SQL-Server. This simply won't be feasible in most
environments.


If original approach with the batch-file excuting the sql-
files via isql is not an option any more, I would rather
use a bat-file to merge all the sql-files to one big sql-
batch before executing the whole thing with Query Analyzer.

Cheers
Phil
 
uh.. i've never worked anywhere without sa priveleges; so i guess it
didnt occur to me lol

btw, does the OP even know about isql?

i was just assuming that is what he was doing..

tell us more about what you're doing; i mean.. there are a zillion ways
to get around using batch and tsql.. i mean.. keep all the defs in a
table; and then it would be easy to write a cursor that would loop
through and create all these objects

just depends on what you're trying to do.. i mean

are you coping a database between prod and test?

are you deploying this for msn and they have hyper-obnoxious setup
routines? (i speak from personal experience lol)

-aaron
 
Back
Top