Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 current activity

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-02-26 : 10:15:00
hello,
is the current activity in the enterprise manager held in a table, ie, can I display the current activity via a sql statement or stored procedure ?

thank you for any info.
Jamie

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-02-26 : 10:24:47
Have a look at sp_who and sp_who2
Go to Top of Page

claire
Starting Member

19 Posts

Posted - 2004-02-26 : 10:28:44
also

master.dbo.sysprocesses
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-02-26 : 10:33:13
cheers ehorn and claire,
I'll look into it.
Go to Top of Page

sphadke
Yak Posting Veteran

55 Posts

Posted - 2004-02-26 : 12:05:08
If you want to store the contents of sp_who or sp_who2 in a table make a copy of the proc call it sp_who_2_<somethinghere>

and in the last SELECT statement use the INTO <table name>

and you are good to go.

eg:
select spid,
ecid,
status,
loginame=rtrim(loginame),
hostname,
blk=convert(char(5),blocked),
dbname = case
when dbid = 0 then null
when dbid <> 0 then db_name(dbid)
end
,cmd
into ##temp
from master.dbo.sysprocesses
where spid >= @spidlow and spid <= @spidhigh

Sachin
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-02-27 : 05:22:29
thanks for the tip Sachin.

can I ask another question , a follow up really,
is it possible to show the sql statements that each spid is running ?
is this info also stored in a system table ?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-27 : 06:11:31
see
http://www.nigelrivett.net/sp_nrSpidByStatus.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-02-27 : 06:57:02
Nigel, nice example, but where the heck are you getting command from ?
is it from running dbcc input buffer against the spid, will that give me the sql statement ?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-27 : 07:24:14
Yep - it runs that against every spid.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -