Are you trying something like this?
SELECT
spid
, blocked
, d.name AS 'db_name'
, nt_username
, loginame
, u.name AS 'user_name'
, net_address
, hostname
, program_name
, cmd
FROM master.dbo.sysprocesses p
LEFT JOIN master.dbo.sysdatabases d
ON p.dbid =3D d.dbid
LEFT JOIN sysusers u
ON p.uid =3D u.uid
ORDER BY=20
p.db_name
, p.loginame
, p.net_address DESC
Have you tried creating a Stored Procedure and calling the stored =
procedure from the application?
--=20
Arnie Rowland, YACE*=20
"To be successful, your heart must accompany your knowledge."
*Yet Another Certification Exam
[quoted text, click to view] "Doug Stephens" <dougstephens@rogers.com> wrote in message =
news:%23Gy4uOjlGHA.2128@TK2MSFTNGP04.phx.gbl...
>I want to see the users who are connected to my databases. Also who is
> blocked and blocking. I know I can see some of this with sp_who and
> related, but I need the info in my program. Same result set =
restriction
> is in effect for those procedures.
>=20
> The info I need seems readily available in sysprocesses and
Yes, much like that.
select b.name, a.hostname, a.spid, a.blocked, a.status, a.cmd
from sysprocesses a, sysdatabases b
where a.hostname<>'' and a.dbid=b.dbid
order by 1 asc
Since running sp_who gives same result, why should I try creating a