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
 General SQL Server Forums
 New to SQL Server Programming
 How to reset the database? (continous integration)

Author  Topic 

vermorel
Starting Member

26 Posts

Posted - 2006-10-28 : 11:18:16
I designing a continuous integration process, and I need to be able to "clean" the SQL Server 2005 database. Locally, I just drop the database and re-create it. That's the simplest way.

Yet, I would like to do the same thing with an "hosted" database online. The problem being that I do not have the rights to drop/recreate the database. Thus I need to operation within the database.

Does anyone has an idea how to drop everything in a database except the database itself?

Thanks in advance,
Joannès
[url]http://www.peoplewords.com[/url]

vermorel
Starting Member

26 Posts

Posted - 2006-10-28 : 12:08:31
Actually I have found the following post
[URL]http://aspzone.com/blogs/john/archive/2006/07/12/1793.aspx[/URL]
that deletes all the tables.

But what about the constraints? (will this script work)
What about the non-table objects of the database? (stored procs for ex)

Joannès
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-10-28 : 14:01:34
This script you refer to will not work if there are foreign keys (unless you get lucky and all the referencing tables get dropped first).

This topic is already discussed here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73397

Post below will truncate all tables. You could easily modify it to drop instead:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65341


SqlSpec - a fast, cheap, and comprehensive data dictionary generator for
SQL Server 2000/2005 and Analysis Server 2005 - http://www.elsasoft.org
Go to Top of Page
   

- Advertisement -