Hi,
I used database A:
use A
go
(do something)
After I worked with a database A, I want to drop it. I need to change to
another database B by issue the coommands
use B
go
drop databse A
go
I wonder if there is a command to "unuse" A so that I do not need use B to
drop A.
Thanks.You do not have to "unuse" the database; instead switch to master & drop the
desired database.
Anith|||Have to be connected to master to do this, not either of the databases you
are playing with. Then, run:
exec sp_detach_db @.dbname='databaseName'
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"§Chrissi§" wrote:
> Hi,
> I used database A:
> use A
> go
> (do something)
> After I worked with a database A, I want to drop it. I need to change to
> another database B by issue the coommands
> use B
> go
> drop databse A
> go
> I wonder if there is a command to "unuse" A so that I do not need use B to
> drop A.
> Thanks.
>
>|||USE master
but why would you want to do something in a database then drop it?
David Portas
SQL Server MVP
--|||Hi,
You can not a drop a database if it is being used by any session. Only way
is to change the session to point to another database
and drop the database.
Thanks
Hari
SQL Server MVP
"Chrissi" <anubisofthydeath@.hotmail.com> wrote in message
news:%23I8VriOUFHA.3176@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I used database A:
> use A
> go
> (do something)
> After I worked with a database A, I want to drop it. I need to change to
> another database B by issue the coommands
> use B
> go
> drop databse A
> go
> I wonder if there is a command to "unuse" A so that I do not need use B to
> drop A.
> Thanks.
>|||It is better for you to explicitly choose which database to reset context to
(ex: USE B) than let SQL Server decide by default. Otherwise, any following
T-SQL commands are not deterministic.
"Chrissi" <anubisofthydeath@.hotmail.com> wrote in message
news:%23I8VriOUFHA.3176@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I used database A:
> use A
> go
> (do something)
> After I worked with a database A, I want to drop it. I need to change to
> another database B by issue the coommands
> use B
> go
> drop databse A
> go
> I wonder if there is a command to "unuse" A so that I do not need use B to
> drop A.
> Thanks.
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment