Re: sql database creation and its ONLINE status



On Aug 6, 12:34 pm, Don84 <tatata9...@xxxxxxxxx> wrote:
Hi,

SQL platform = MS SQL Server 2005 Express
OS  = XP | Vista

Question, when I use a script to create a db, say, myDB, and then
verify its existence/availability by "select databasepropertyex
('myDB', 'STATUS') command.  Do I have to wait for some time after
creation for its availabity?

The process goes like this:
a) launch isqlw.exe to execute dbCreation.sql -- to create myDB
database; (the script may have some minor/harmless error)
if  the DOS batch errorlevel is 0, consider db creation successful and
go to next, that is, b)
b) launch isqlw.exe again to run the db STATUS command and output it
to a log file named db.log to verify the db availability.

Test outomes on the XP machine.
CASE A, works as designed
CASE B,  the verification process complained about "Unable to save
db.log file because it's being used by another process" something and
later I didn't even find the log.txt file.
Also, the mdf and ldf files for the db have been created.

So, the question is, is there a requirement / an interval required
between db creation and its ONLINE status, if so, how much time?  So,
I'll add delay between them.

Another question, is there a query like
update databasepropertyex('myDB','ONLINE')
to bring it ONLINE?

Thanks.

Code looks like this, once again between db creation and its online
status, any time interval required? thks.

REM startServer
net start "sql server (SQL2005EXPRESSKN)" >nul
goto create

:create
c:\isql\isqlw.exe -S(local)\SQL2005EXPRESSKN -E -ic:\KNBinstall
\createmyDB.sql -oresult.log
if %errorlevel%==0 goto verifyDB
if %errorlevel%==1 goto dbCreationErr

:dbdbCreationErr
echo db creation error
goto :eof

:verifyDB
rem verfy db installation
c:\isql\isqlw.exe -S(local)\SQL2005EXPRESSKN -E -ic:\KNBinstall
\verify_db.sql -odb.log
find "ONLINE" db.log >NUL
if %errorlevel%==0 goto noth

:noth
exit
.



Relevant Pages


Loading