How to logout all user exept myself on a SQL-6.5 DB

I need to find a way to logout all user exept myself from a SQL-6.5 Server DB in order to swtich the database temporally to 'single user'.
Does anybody have a procedure for that ?
scheuringAsked:
Who is Participating?
 
lcsqCommented:
Hi, guys,

all the info are in master..sysprocesses.

Just do this:
select 'kill '+convert(char(100),spid)+char(13)+char(10)+'go' from sysprocesses p,sysdatabases d
where d.name='your_db' and p.dbid=d.dbid

It will generate a script dynamically, and run it. But there are some risks. If some users log out after the script generated, you can kill the invalid users.

So in the production systems, be polite to users, and always call them directly.

Good luck!
0
 
jjbyersCommented:
Stop SQL Server, it will logout all users and then start in single user mode from the command-line.

Hope this helps.
0
 
scheuringAuthor Commented:
I can not stop the hole SQL-Server. I need a way to just logout all user on a specific database.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
jjbyersCommented:
use "sp_option dbname,dbo use only,true" and wait for everyone to get off.
Use "sp_option dbname,offline,true" to take it offline
use "sp_option dbname,single user,true" to open in single user mode.
0
 
tschill120198Commented:
Are you looking for more immediate action, like a script that kills all spids?
0
 
wpdCommented:
Use the 'Server Activity' option in SQL Entreprise Manager, and kill all the processes that access your db. Don't worry, only the connections will be broken :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.