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)
 Disconnect users from a database

Author  Topic 

Bex
Aged Yak Warrior

580 Posts

Posted - 2005-04-26 : 11:50:07
Hey all

I have looked, I have searched, and yet I have so far been unsuccessful! So what do i do? Turn to my favourite forum and ask you lot for answers instead. Basically, is there a stored procedure/function/statement/etc that I can use to disconnect all users from a database?

The reason being is that I was trying to restore a database from backup, however, could not do so as there were supposedly users (or applications) still connected to the database, even though all sweared they were not, and process info confirmed this. There are a couple of applications that use the database and also some excel spreadsheets.

I can only seem to do this sort of work (restorations, importing, e3xporting data) early in the morning when no-one is around. Ideally, i would like to be able to throw users off (perhaps warning them first) so I can take a database off line. Now I remember reading something about this somewhere, but cannot for the life of me remember where, hence my plea for help.

Also, what sproc details all the current connections?

Thanks

Hearty head pats

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-04-26 : 11:52:15
sp_who and sp_who2
kill all the proccesses you want.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Bex
Aged Yak Warrior

580 Posts

Posted - 2005-04-26 : 11:59:43
Lol, well, 'who' seems kinda obvious now! Thanks for getting back to me so quickly Spirit!!! :{) (thats my mexican smiley face with a big moustache)

Hearty head pats
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-04-26 : 12:01:55
i don't even wanna imagine you with a moustache
feels like a tri-state gender column all over again... see yak corral for more info

Go with the flow & have fun! Else fight the flow
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-26 : 12:44:20
ALTER DATABASE <databasename> SET SINGLE_USER WITH ROLLBACK IMMEDIATE


Brett

8-)
Go to Top of Page
   

- Advertisement -