SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Run SQL/T-SQL scripts on folder


Run SQL/T-SQL scripts on folder

Author
Message
daniel_marques
daniel_marques
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 145
Comments posted to this topic are about the item Run SQL/T-SQL scripts on folder
Dan Bragg
Dan Bragg
Old Hand
Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)Old Hand (325 reputation)

Group: General Forum Members
Points: 325 Visits: 91
What I've found to be very handy when writing batch files like this is to have an option to get a reminder of what the batch does, and what parameters are to be expected (if any) and to ensure that you've remembered to set the internal values before running. In your case, as no parameters are expected, if passed a ?, it could give instructions. It usually takes the form of something like this:

(at the very beginning of the batch file)
if "%1"=="?" then GOTO :Instructions

(near the end of the file, as the last line of functioning code)
GOTO :EOF

:Instructions
ECHO.
ECHO BatchSQL (no parameters)
ECHO pathScripts = %pathScripts%, pathlogs=%pathlogs%
ECHO.
ECHO This batch will execute all .SQL scripts stored in %pathScripts% and output the results of the scripts in separate files within %pathlogs%.
ECHO Note: If the pathScripts and pathlogs are incorrect above, they are set within the batch itself.
ECHO.
GOTO :EOF
Jonathan AC Roberts
Jonathan AC Roberts
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13774 Visits: 5771
One of our systems has about 500 stored procedure scripts that need to be run on a release. To do this I concatenate all the scripts together in one file. At the DOS prompt you just need to type the following:
COPY *.sql all.txt
REN all.txt all.sql
You then have a file (all.sql) containing all the scripts in one file. You have to make sure they are all saved with the same encoding (I use ASCI) and all the procedure scripts have a GO and new line at the end.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search