Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Return count of logged on users

0 views
Skip to first unread message

David Lownds

unread,
Mar 18, 1999, 3:00:00 AM3/18/99
to
Hi,

This has probably been asked 100's of times but I am new to sql server.

I need to know how many users are currently logged on to my database so that
i can display this value on a vb form.

i am using sql server 6.5 and vb6. sp_who nearly does what i want but i
can't limit the rows just to my database

Any help would be much appreciated

Dave Lownds
HEBS

Tibor Karaszi

unread,
Mar 18, 1999, 3:00:00 AM3/18/99
to
Dave,

Below is for the pubs database:

--Number of connections
SELECT COUNT(*) FROM master..sysprocesses WHERE dbid = db_id('pubs')

--Number of users, first is 7.0, second is 6.x
SELECT COUNT(DISTINCT sid) FROM master..sysprocesses WHERE dbid =
db_id('pubs')
SELECT COUNT(DISTINCT suid) FROM master..sysprocesses WHERE dbid =
db_id('pubs')


--
Tibor Karaszi, ti...@cornerstone.se
MCSE, MCSD, MCT, SQL Server MVP
Cornerstone Sweden AB
Please do not respond by e-mail unless explicitly asked for.

David Lownds wrote in message <#wZtPiVc#GA.204@cppssbbsa03>...

David Lownds

unread,
Mar 19, 1999, 3:00:00 AM3/19/99
to
Many thanks it works a treat !!


Tibor Karaszi wrote in message ...

0 new messages