ok here's one way to do it with SQL2000:
declare @sql_handle-2 binary(20),@spid smallint;
declare c1 cursor for select sql_handle,spid from master..sysprocesses where spid >50;
open c1;
fetch next from c1 into @sql_handle-2,@spid;
while (@@FETCH_STATUS =0)
begin
select
spid,
login_time,
last_batch,
[status],
loginame,
a.text
from ::fn_get_sql(@sql_handle) a, master..sysprocesses b
where b.spid = @spid
fetch next from c1 into @sql_handle-2,@spid
end
close c1
deallocate c1;
Lowell