|
smithsf22
Starting Member
9 Posts |
Posted - 05/16/2007 : 15:16:16
|
Hello, I have a small batch file that will run all of the *.sql files in the same folder. My question is: is there a way to first test that I can see the DB so I can oputput an error if I cant? Here is what I have so far:
@echo off echo ++++++++++++++++++++ echo Runs all SQL scripts that do not require parameters within the echo same folder as this batch file. Echo ++++++++++++++++++++ SET ServerName= SET /P ServerName=Please enter the Server Name: SET DatabaseName= SET /P DatabaseName=Please Enter Database Name:
REM IF I can connec to DB continue REM ELSE goto :NoConn
for /f %%a in ('dir /b *.sql') do call :Process %%a goto :Done :Process echo Running: %1 osql -E -S %ServerName% -d %DatabaseName% -n -i %1 > Report.txt
:NoConn echo error cannot connect to Database.
:Done echo Operation completed. Pause
Thanks |
|