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 2000 Forums
 SQL Server Development (2000)
 detaching database

Author  Topic 

Clages1
Yak Posting Veteran

69 Posts

Posted - 2007-04-28 : 18:45:41
Hi

I know if I use

EXEC sp_detach_db 'pubs', 'true'

The database will detached but only if there are no users logged in the database.

How can i Logged out (drop out) all the Uses
so i can Detach database?

Tks

CLages



spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-04-28 : 19:15:33
ALTER DATABASE DatabaseName
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Clages1
Yak Posting Veteran

69 Posts

Posted - 2007-05-01 : 10:35:48
Hi
I still get the same message

Cannot detach the database 'teste' because it is currently in use.

I saw in BOL , Single user Bring the database to one User
and Detach to work fine needs NOUSERS

tks

C. Lages
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-05-01 : 13:43:39
Don't run 'ALTER DATABASE' under the db you need to detach. Also ensure apps use that db don't reconnect to it automatically.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-01 : 13:47:23
right click on the db -> All tasks -> Detach db. It will tell you if there are any connections. You can kill them from the same window.

Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Clages1
Yak Posting Veteran

69 Posts

Posted - 2007-05-02 : 11:05:45
Tks
with RMIAO sugestion works fine

tks
Clages
Go to Top of Page
   

- Advertisement -