Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Regarding Number of User

Author  Topic 

laksivanna
Starting Member

4 Posts

Posted - 2006-12-07 : 03:18:47
I want to know. how may user using the same database in online.
How I'll find

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-07 : 03:39:54
You want to know how many users are simultaneously connected to the database right now?
You want to know how many users accounts there are in the database?



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-07 : 04:02:21
[code]EXEC sp_who[/code]
or

[code]EXEC sp_who2[/code]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

laksivanna
Starting Member

4 Posts

Posted - 2006-12-07 : 04:15:34
I want to know how many users are simultaneously connected to the database right now?


Regards
Siva Anandan
Go to Top of Page

laksivanna
Starting Member

4 Posts

Posted - 2006-12-07 : 04:35:45
SELECT db.name, COUNT(db.name) AS NumberofUser
FROM master.dbo.sysprocesses as pro INNER JOIN
master.dbo.sysdatabases as db ON pro.dbid = db.dbid
GROUP BY db.name

Laksivanna
Knowledge is sharable
Go to Top of Page

laksivanna
Starting Member

4 Posts

Posted - 2006-12-07 : 06:41:11
SELECT db.name, COUNT(pro.dbid) AS NumberofUser
FROM master.dbo.sysprocesses as pro RIGHT JOIN
master.dbo.sysdatabases as db ON pro.dbid = db.dbid
GROUP BY db.name


Laksivanna
Knowledge is sharable
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-07 : 06:46:12
Good try, but that only gives how many processes are connected to each and one database, not the number of unique users.
SELECT		db.name DbName,
count(pro.loginame) Connections,
count(distinct pro.loginame) Users
FROM master..sysdatabases as db
LEFT JOIN master..sysprocesses as pro ON pro.dbid = db.dbid and left(pro.sid, 2) in (0x0105, 0x0100) and pro.lastwaittype = 'networkio'
GROUP BY db.name

Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -