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.
| Author |
Topic |
|
Bex
Aged Yak Warrior
580 Posts |
Posted - 2005-04-26 : 11:50:07
|
| Hey allI 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? ThanksHearty head pats |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-04-26 : 11:52:15
|
sp_who and sp_who2kill all the proccesses you want. Go with the flow & have fun! Else fight the flow |
 |
|
|
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 |
 |
|
|
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 |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-04-26 : 12:44:20
|
| ALTER DATABASE <databasename> SET SINGLE_USER WITH ROLLBACK IMMEDIATEBrett8-) |
 |
|
|
|
|
|
|
|