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 2005 Forums
 Transact-SQL (2005)
 How to delete a database.

Author  Topic 

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-23 : 06:15:20
Hi..
one of my database SID-TRR currently not in use as i created it for storing my test tables.
now i would like to delete the database,can you suggest with sql code.

Thanx in advance.

Satya

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-23 : 06:33:54
If you are *absolutely* sure that nothing is using it then you can just delete it through management studio.

If there are legacy connections and you are ABSOLUTELY SURE that you don't need the database then you can do this

ALTER DATABASE <database> SET OFFLINE WITH ROLLBACK IMMEDIATE
DROP DATABASE <database>


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -