SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Test that I can see database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

9 Posts

Posted - 05/16/2007 :  15:16:16  Show Profile  Reply with Quote
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

echo Running: %1
osql -E -S %ServerName% -d %DatabaseName% -n -i %1 > Report.txt

echo error cannot connect to Database.

echo Operation completed.

  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000