I just restored a database and want to delete it (part of testing things). It is telling me that it cannot be deleted because it is in use. No one is using it. How do I get rid of it?
Thanks
USE master
GO
ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
DROP DATABASE dbname
GO
http://www.aspfaq.com/
(Reverse address to reply.)
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:CF19874A-09FD-4B05-8C78-7A9C51BFD3B0@.microsoft.com...
> I just restored a database and want to delete it (part of testing things).
It is telling me that it cannot be deleted because it is in use. No one is
using it. How do I get rid of it?
> Thanks
|||Perhaps you have an open connection from Query Analyzer on your machine.
/*this shows the connections and what database each is using: */
exec sp_who2
go
You could KILL a SPID or you can run this command (remove the comment block
first) to set the database to single user mode:
/*
ALTER DATABASE <YourDBName> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
*/
Keith
"Niles" <Niles@.discussions.microsoft.com> wrote in message
news:CF19874A-09FD-4B05-8C78-7A9C51BFD3B0@.microsoft.com...
> I just restored a database and want to delete it (part of testing things).
It is telling me that it cannot be deleted because it is in use. No one is
using it. How do I get rid of it?
> Thanks
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment