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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dropping and recreating DB's in DTS

Author  Topic 

Bex
Aged Yak Warrior

580 Posts

Posted - 2005-07-12 : 05:37:05
I have three identical databases residing on the same server:

Developer_ArchiveIndex - For developing, playing with code, etc
Prototype_ArchiveIndex - For Customer Acceptance tests
Test_ArchiveIndex - The test suite

The test database is the most important, as we have a number of tests automatically run against the DB every night. To ensure the database is in exactly the same state for each test, it is dropped, recreated and repopulated via a scheduled DTS package. I wanted to do the same for all databases, and run the script to generate the DB and run sp_renameDB to rename it for each of the three databases using the same script. However, the MDF and LDF files do not appear to be renamed causing the following error:

cannot create file 'e:\mssql\data\Test_ArchiveIndex.mdf' because it already exists

How can I overcome this, or is there a simpler way to do it?



Hearty head pats

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-07-12 : 16:48:42
Create all of the objects in the model database, recommend a separate instance!
execute drop database
execute create database
all objects will be created exactly as they are in the model db and you can create as many of these as you like

You can do anything at www.zombo.com
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-07-12 : 19:40:39
I'm missing something here aren't I. Why don't use just use the RESTORE command with the WITH MOVE option???

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -