Solved

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

Posted on 1999-01-26
6
1,082 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query help 15 55
Convert VBA UDF to SQl SERVER UDF 4 51
sql server cross db update 2 20
TSQL: return only records which have only one type of value. 1 16
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 …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

726 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