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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
lcsqConnect With a Mentor Commented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
All Courses

From novice to tech pro — start learning today.