Solved

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

Posted on 1999-01-26
6
1,080 Views
Last Modified: 2008-02-20
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 ?
0
Comment
Question by:scheuring
6 Comments
 
LVL 3

Expert Comment

by:jjbyers
ID: 1092847
Stop SQL Server, it will logout all users and then start in single user mode from the command-line.

Hope this helps.
0
 

Author Comment

by:scheuring
ID: 1092848
I can not stop the hole SQL-Server. I need a way to just logout all user on a specific database.
0
 
LVL 3

Expert Comment

by:jjbyers
ID: 1092849
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Expert Comment

by:tschill120198
ID: 1092850
Are you looking for more immediate action, like a script that kills all spids?
0
 
LVL 2

Expert Comment

by:wpd
ID: 1092851
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
 

Accepted Solution

by:
lcsq earned 100 total points
ID: 1092852
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

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question