Friday, March 9, 2012

Getting Number of Logged On Users to Server

SQL Server 2000 - MSDE 2000

Is there a way to get the number of current users logged into a SQL 2000 Server (also MSDE)? Cant be distinct users as most users are logged into the database using the same login.

--
Tim Morrison

------------------------

Vehicle Web Studio - The easiest way to create and maintain your vehicle related website.
http://www.vehiclewebstudio.comTim Morrison (sales@.kjmsoftware.com) writes:
> SQL Server 2000 - MSDE 2000
> Is there a way to get the number of current users logged into a SQL 2000
> Server (also MSDE)? Cant be distinct users as most users are logged into
> the database using the same login.

select count(*) from master..sysprocesses where spid > 50 will give you
a rough number. This will include logins from SQL Agent. Note that the
same user can be using multiple connections from the same application,
and thus be counted more than once.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||hmmm.... thanks for the info. Im surprised there isnt a more definate way
to get this information from SQL.

Tim Morrison

"Erland Sommarskog" <sommar@.algonet.se> wrote in message
news:Xns9445430E3C3FYazorman@.127.0.0.1...
> Tim Morrison (sales@.kjmsoftware.com) writes:
> > SQL Server 2000 - MSDE 2000
> > Is there a way to get the number of current users logged into a SQL 2000
> > Server (also MSDE)? Cant be distinct users as most users are logged into
> > the database using the same login.
> select count(*) from master..sysprocesses where spid > 50 will give you
> a rough number. This will include logins from SQL Agent. Note that the
> same user can be using multiple connections from the same application,
> and thus be counted more than once.
>
> --
> Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||I see that one of the fields is "program_name" in the sysprocesses table. I
have Crystal Reportsrunning so that is one of the processes. How do I get my
app to report itself as one of those processes like crystal?

Then I can do a 'SELECT count(*) FROM sysprocesses WHERE program_name =
'MyApp'.

TIA

Tim Morrison
"Erland Sommarskog" <sommar@.algonet.se> wrote in message
news:Xns9445430E3C3FYazorman@.127.0.0.1...
> Tim Morrison (sales@.kjmsoftware.com) writes:
> > SQL Server 2000 - MSDE 2000
> > Is there a way to get the number of current users logged into a SQL 2000
> > Server (also MSDE)? Cant be distinct users as most users are logged into
> > the database using the same login.
> select count(*) from master..sysprocesses where spid > 50 will give you
> a rough number. This will include logins from SQL Agent. Note that the
> same user can be using multiple connections from the same application,
> and thus be counted more than once.
>
> --
> Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||You can specify it in the connection string, something like "Application
Name = etc" Its documented in the ADO/OLE DB/ODBC connection strings
documentation.

"Tim Morrison" <sales@.kjmsoftware.com> wrote in message
news:CxQyb.381793$HS4.3135751@.attbi_s01...
> I see that one of the fields is "program_name" in the sysprocesses table.
I
> have Crystal Reportsrunning so that is one of the processes. How do I get
my
> app to report itself as one of those processes like crystal?
> Then I can do a 'SELECT count(*) FROM sysprocesses WHERE program_name =
> 'MyApp'.
>
> TIA
> Tim Morrison
> "Erland Sommarskog" <sommar@.algonet.se> wrote in message
> news:Xns9445430E3C3FYazorman@.127.0.0.1...
> > Tim Morrison (sales@.kjmsoftware.com) writes:
> > > SQL Server 2000 - MSDE 2000
> > > > Is there a way to get the number of current users logged into a SQL
2000
> > > Server (also MSDE)? Cant be distinct users as most users are logged
into
> > > the database using the same login.
> > select count(*) from master..sysprocesses where spid > 50 will give you
> > a rough number. This will include logins from SQL Agent. Note that the
> > same user can be using multiple connections from the same application,
> > and thus be counted more than once.
> > --
> > Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
> > Books Online for SQL Server SP3 at
> > http://www.microsoft.com/sql/techin.../2000/books.asp

No comments:

Post a Comment