Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing a db with a "reset" .mdf daily

Status
Not open for further replies.

NewFromMattel

Programmer
Jun 24, 2003
41
US
Here's my delimma. I have a demo database that needs to have "seeded" data in it that can be manipulated daily during demos. But at night I want to return to the default seeded version.

What I'm doing is:
killing the spids for this db.
detaching the db
moving the 2 files (mdf and ldf) to an archive folder
copying 2 default seeded files to the database folder
attaching the new files.

However the transactions are being rolled forward upon attaching! How can I prevent this??

Thanks

And I am calling this from a .exe file (written in C#)
 
Wouldn't it be much easier to just make a backup of your database when it is it's "clean state" and then do a restore the database before a demo... No need to detach reatach.. The only negative is if your DB spans GB it might take a while...

Backup Database YourDB to disk='c:\cleandb.bak' with init

Now all you need to do is execute the following code from a command or connection...

restore Database YourDB from disk='c:\cleandb.bak'


My 1c


Rob
 
Oh yea an then at the end of a demo you make a differential backup of teh db.. That way you can easily and quickly get back to a state at the end of your demos.. Would take up much less diskspace also...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top