cancel
Showing results for 
Search instead for 
Did you mean: 

Query to list connected users

Former Member
11,979

Using SQL, how can I get the same list as "Connected Users" tab in Sybase Central? (SQL Anywhwere 9.0)

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

I guess

call sa_conn_info()

will give you the desired information - at least partially. Here's the doc for 12.0.1.

Former Member

Thanks for the pointer. I found sa_conn_activity procedure that does a similar job and altered it to include some other properties I needed.

MarkCulp
Participant

I hope by "altered it" you really mean that you defined your own procedure with a different name with similar code? If not, then I highly recommend that you not actually change the definition of dbo.sa_conn_activity() because if you do you will lose your definition (and it will be revert back to the original) if you ever unload/reload your database or do a ALTER DATABASE PROCEDURE ON.

VolkerBarth
Contributor
0 Kudos

or an "ALTER DATABASE UPGRADE PROCEDURE ON" - yes, one of my current favourites:)

Former Member
0 Kudos

I had to change the actual procedure. Yeah, I know. I tried to define my own but there's a "next_connection" function call inside and I cannot access it in my own procs (is that possible?). Actually this is all about monitoring incoming queries to the server. My .NET program saves a copy of the original definition and pushes its own version. So both versions are safe. There might be a better way to do the same thing, but I haven't come across any yet.

VolkerBarth
Contributor
0 Kudos

Of course you can use the next_connection() function in your own code - typically in a loop, e.g. something like

declare nConnId integer;
set nConnId = (select next_connection(null));
while nConnId is not null loop
  -- do something with nConnId
  set nConnId = (select next_connection(nConnId));
end loop;
Former Member
0 Kudos

You can type only: select number from sa_conn_info();

VolkerBarth
Contributor
0 Kudos

Sure you can. However, here my point was to show how to use a next_connection() loop...

Answers (0)