Hi,

I am trying to create the database TempDB on my MSDE instance:

This is my batch file:

@ECHO off
echo Creating Database.............
SETLOCAL

IF EXIST %ProgramFiles%\Microsoft SQL Server\MSSQL$MyInstance\Data\TempDB.mdf.
del "%ProgramFiles%\Microsoft SQL Server\MSSQL$MyInstance\Data\TempDB.mdf" 0>>NUL

IF EXIST %ProgramFiles%\Microsoft SQL Server\MSSQL$MyInstance\Data\TempDB_log.LDF.
del "%ProgramFiles%\Microsoft SQL Server\MSSQL$MyInstance\Data\TempDB_log.LDF" 0>>NUL

osql -U sa -S %COMPUTERNAME%\MyInstance -P password -i createTableScript.sql 0>>Nul

ENDLOCAL
pause

and this is createTableScript.sql :
---------------------------------------
CREATE DATABASE TempDB
go
use TempDB
go


CREATE TABLE Table1 (
Name VARCHAR (64),
Age numeric,
)
go

----------------------------------------

Now ,if I run my batchfile for the first time ,it works fine.But from the second time onwards although it creates the database( new TempDB.mdf and TempDB.ldf files are created) successfully, the script shows following errror mesaages.

Device activation error. The physical file name 'C:\Program Files\Microsoft SQL
Server\MSSQL$MyInstance\Data\TempDB.mdf' may be incorrect.
Device activation error. The physical file name 'C:\Program Files\Microsoft SQL
Server\MSSQL$MyInstance\Data\TempDB_log.LDF' may be incorrect.


How can I overcome this?

Thanks .
KT.