471,107 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,107 software developers and data experts.

How i can see how many user using database?

Hello,

I want do some store procedure for see how many users using database in this exactly moment.
I want do this because i need to stop DB for execute backup or restore.

And how i can kill all conection for do this.

thanks. Sorry i am learning !
Dec 4 '06 #1
4 2259
I see existe sp_who and sp_who2 , how i can filter user de one db ? example only msdb

Thanks
Dec 4 '06 #2
iburyak
1,017 Expert 512MB
Try this select statement to view connected users.

select spid, loginame,b.name db_name, hostname, program_name,a.status,
login_time, last_batch, lastwaittype
from master..sysprocesses a
join master..sysdatabases b on a.dbid = b.dbid


To kill all connections at once I would set server in single user mode and kill that last connection and login by myself.
The thing is as soon as you kill all connections they still can connect back.
Dec 4 '06 #3
Well i used one store procedure for filters users, databases etc....

But now i dont know how i can see how many users ( only number ) is connected in one database and put one button in one windows aplication for kill all users.

thanks
Dec 5 '06 #4
I already resolve problem for kill users. Now i just know how i can put in windows aplication some messsage ( Have x users conected in db )
Dec 5 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by Joshua Beall | last post: by
1 post views Thread by DC_DBA | last post: by
6 posts views Thread by Jerry Spence1 | last post: by
3 posts views Thread by Patrick Olurotimi Ige | last post: by
3 posts views Thread by Michael Glaesemann | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.