Run Multiple Stored Procedures in order with a script??

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Tom (none_at_none.com)
Date: 11/21/04


Date: Sun, 21 Nov 2004 15:32:16 -0500

Hello. I have to run many sql scripts each day. Sometimes I'll have 100+
scripts to run. The scripts always come in a folder numbered in the order
they need to be run (001 - ScriptA, 002 - ScriptB, etc.).

I've been running them all manaully one by one so that I can look for errors
in the results. I'd love to be able to point a batch file to the folder
with all the scripts, have them run one by one, and have the results output
in one file with:

Results.txt:
001 - ScriptA.sql
Command Completed Successfully

----
002 - ScriptB.sql
Command Completed Successfully
---
003 - ScriptC.sql
Error in line 1...etc
---
004 - ScriptD.sql
Command Completed Successfully
---
etc.
I have tried piping them using c:\Scipts\*.sql  >  c:\AllScripts.sql
However, this is often causes problems as sometimes the end of one script
will join directly to the start of the first script making statements that
don't exist (EndscriptGo).. two statements joint into one.  Or other times
scripts will be left out for some reason.  Piping has caused many problems
and isn't trusted anymore.
I tried using osql
OSQL -Usa -Ppass -Sdb123 -iC:\scripts\001scriptA.sql -oC:\logs\001scriptA.lo
g
but I don't know how to run scripts 001 through say 108 in order, or how to
have them output into one file.
Is there a way to use this or something else (like run 001*.sql, then run
001+1*.sql [I have no idea how to program!) so that I can just point it to
the folder with the numbered scripts and have them run one by one in order??
Any help is REALLY REALLY appreciated!!!!
Thank you


Relevant Pages

  • Re: Cant copy .exe to Startup Scripts Folder on DC
    ... Not sure "scripts\startup folder for an OU" means; do you mean the scripts folder for the particular GPO? ... In Group Policy Editor, in Windows Settings, Scripts, double click Logon, Logoff, Startup or Shutdown as appropriate. ... Microsoft Global Technical Support Center ... | Subject: RE: Can't copy .exe to Startup Scripts Folder on DC ...
    (microsoft.public.windows.group_policy)
  • Re: can not create folder called scripts anymore
    ... There are already scripts folder everywhere..but they are ... Something in windows itself seems to hide and block everything called ...
    (microsoft.public.win2000.general)
  • Re: Automating details view?
    ... untick saving individual folder view and set the folder view ... then set what I want and reboot. ... It's just that the Win+E key combination and my many scripts use WE ... WE replacement. ...
    (microsoft.public.windowsxp.basics)
  • Re: can not create folder called scripts anymore
    ... "Pegasus (MVP)" wrote: ... scripts, ... I got the LPT1 folder but no script folder... ...
    (microsoft.public.win2000.general)
  • Re: oSQL - How do I run all .SQL files in a folder by running one batch
    ... the scripts in the folder. ... ECHO Please specify a folder like this: ... you can get the batch file to do that for you: ...
    (microsoft.public.sqlserver.connect)