Bhaskar
Bhaskar

Reputation:

how to know how many users are connected to a particular database in sqlserver2000

how to know how many users are connected to a particular database

Upvotes: 1

Views: 3161

Answers (3)

LeoPasta
LeoPasta

Reputation: 300

SELECT COUNT(DISTINCT spid)
FROM master.dbo.sysprocesses
WHERE spid >= 50
AND dbid = DB_ID('MyDBName')

Upvotes: 0

gbn
gbn

Reputation: 432667

For a simply query, you can use this on SQL 2000 to SQL 2008 (there is no 1:1 replacement for sysprocesses in SQL 2005)

SELECT
    COUNT(*)
FROM
    MASTER..sysprocesses
WHERE
    dbid = DB_ID('MyDBName')

Upvotes: 0

Robin Day
Robin Day

Reputation: 102558

You can use the stored procedure sp_who2

Upvotes: 1

Related Questions