Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
smithsf22
Starting Member
9 Posts |
Posted - 2007-05-16 : 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 continueREM ELSE goto :NoConnfor /f %%a in ('dir /b *.sql') do call :Process %%a goto :Done :Processecho Running: %1osql -E -S %ServerName% -d %DatabaseName% -n -i %1 > Report.txt:NoConnecho error cannot connect to Database.:Doneecho Operation completed. PauseThanks |
|
|
|
|