views:

467

answers:

4

Hi

If I have scripts in multiple files, and I would like to execute each one in a known sequence, can I simply import them into a T-SQL script and execute them, or must I run sqlcmd or similar against each file? I'm sure Oracle has a feature to import/include script content from another file (maybe with @@ ?).

I want all of the scripts to run automatically. I.e. I don't want to manually load and run each file of SQL script.

A: 

I think you can import them into a T-SQL script and execute. Better yet though, use SSMS and a maintenance plan. That way you can run the individual SQL and have some checks on success before executing the next statements.

MkUltra
+1  A: 

You can concatenate the scripts into a single file. Place a GO statement at the end of each file (if it doesn't already have one) and it should be fine to run as one file instead of multiple.

Nick Kavadias
+1  A: 

If you want to run the scripts automatically I'd make a batch file which calls osql for each file.

-Edoode

edosoft
This is what I ended up doing, though I invoked sqlcmd, not osql.
Bernhard Hofmann
A: 

We have a free simple tool you can use as well - it is called Script Executor - the community edition (http://www.xsqlsoftware.com/Product/Sql_Server_Script_Executor.aspx) allows you to add individual scripts and folders containing scripts, order them and execute. There is a command line option as well in case you need to schedule the execution to run automatically.