Apologies if this seems very trivial, would you happen to know if I can consolidate a bunch of scripts (17 to be exact) into just one job? Would it be a simple matter of copying them all into just one script; adding 'end' at the end of each script etc? Or is there another way? can I attach them all to one maintenance plan or job for instance? If so, can you tell me the exact steps I need to take in order to do this? Currently I'm executing 1 script at a time, waiting for the result, and then executing another script. The scripts are designed to upgrade the database they are referring to, which it does manage to do successfully.
Any help in this matter is greatly appreciated.
Answer by Matt Whitfield ·
If you want to run them through Enterprise Manager, Query Analyser or some other IDE then you can just make one big file with 'GO' on a line on it's own between each file's text.
If you want to run it from C# or something, then just read the files in sequentially and fire each one in a batch at the server.
You will want some error handling in there, though...
Answer by Grant Fritchey ·
It really depends on what each of these scripts is doing. As a general concept can you copy & paste them all together? Sure, but, at the very least, you'll probably want to wrap each one with a BEGIN and END statement. You may want to add error handling if you don't have it already.
From your description these are a serious of data definition language scripts, changing tables, adding procedures, that sort of thing? You should be able to join them all together.