Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

What is sysprocesses and what can it do for you? Expand / Collapse
Author
Message
Posted Thursday, April 30, 2009 10:59 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, March 17, 2014 4:32 PM
Points: 91, Visits: 351
Comments posted to this topic are about the item What is sysprocesses and what can it do for you?
Post #708252
Posted Friday, May 1, 2009 4:59 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, January 2, 2013 12:15 PM
Points: 1,443, Visits: 711
Question - how does this relate to sp_who and sp_who2, and the activty monitor in SSMS?
Post #708338
Posted Friday, May 1, 2009 7:20 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, December 12, 2014 9:23 AM
Points: 206, Visits: 402
Thanks for a great review. For those of us who have been using sysprocesses as well as sp-who, sp_who2 for along time, it never hurts to have a review.

BTW.. sp_who & sp_who2 use info from sysprocesses.
sysprocesses goes back to the original Sybase design, so it has been around for a while.


The more you are prepared, the less you need it.
Post #708416
Posted Friday, May 1, 2009 7:44 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
Good review of sysprocess table. Every DBA should know about this table. Though I know a couple of ones who are used to using sp_who2 but does have no idea where the data comes from.

2005 and 2008 has an extra column request_id.


SQL DBA.
Post #708444
Posted Friday, May 1, 2009 10:42 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, March 17, 2014 4:32 PM
Points: 91, Visits: 351
Hi Mark,

Thanks Andrew and Sanjay.

The sysprocesses table is wrapped by sp_who* and the activity monitor but they do not give you as much detail, if you look at the definition for sp_who it is:

CREATE PROCEDURE sys.sp_who <snip />
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
,request_id
from master.dbo.sysprocesses
where spid >= @spidlow and spid <= @spidhigh

so it is useful but I think when troubleshooting issues knowing how to use sysprocessses and what everything means is essential.

It is also good for scripting because for instance you can join against itself on blocked = spid to get information on what queries are being blocked and also what it is that is blocking them.




Ed
Post #708595
Posted Monday, May 4, 2009 12:12 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Saturday, November 29, 2014 3:55 PM
Points: 3,244, Visits: 5,010
What a co-incidence...

On thursday, I was struggling to get the Detailed information for each column in sys.sysprocesses. And here we are....

Very useful article, especially for me.

Thanks


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

Sometimes, winning is not an issue but trying.

You can check my BLOG here

Post #709194
Posted Tuesday, May 5, 2009 11:24 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 10:22 AM
Points: 914, Visits: 2,051
A friend of mine wanted to conduct a license audit of her installation and used sysprocesses to get the info. On each server she created a DTS job that ran the following query:
select getdate() as StatsDate, ss.srvname as ServerName, 
rtrim(db.name) as DBName, rtrim(hostname) as HostName,
rtrim(program_name) as ProgramName, rtrim(nt_domain) as Domain,
rtrim(nt_username) as UserName, rtrim(net_address) as MACAddress,
rtrim(loginame) as LoginName
from master..sysprocesses sp
join master..sysdatabases db
on sp.dbid = db.dbid
cross join master..sysservers ss
where sp.loginame <> 'sa'
order by db.name, hostname, loginame

then wrote it to a text file. She ran it at the top of the hour, on some days every 5 or 15 minutes, over an extended period of time and collected the scripts on her machine via a scheduled task that ran at 5 minutes after the hour that did this:
copy C:\SQLUserStats\ConnectionStats.txt + \\server1\c$\SQLUserStats\sqluserstats.txt C:\SQLUserStats\ConnectionStats.txt
copy C:\SQLUserStats\ConnectionStats.txt + \\server2\c$\SQLUserStats\sqluserstats.txt C:\SQLUserStats\ConnectionStats.txt
etc.

Worked like a charm. Suck the text file into a table and you can slice and dice the data to your heart's contentment.

One thing it would not show: if connections came through a gateway or application server that could spoof a MAC address or user name, you could have several dozen users hidden that you won't readily see. You also wouldn't see users who logged in for less than an hour and didn't cross that top of the hour boundary, so there were days that it ran every 15 minutes or every 5 minutes. Still, it was deemed adequate by her management to give a reasonable number of user connections.

Regardless, sysprocesses saved a whole lot of work for her.


-----
Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson
Post #710495
Posted Thursday, August 13, 2009 8:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 8:08 AM
Points: 2, Visits: 195
Wayne West (5/5/2009)
A friend of mine wanted to conduct a license audit of her installation and used sysprocesses to get the info...

I'm doing something similar. I'm checking sysprocesses every 5 minutes to look for users with certain patterns.
I ended up here because I have been seeing one user whose sessions sometimes show up without a value in loginame! I used Profiler to watch logins and logouts and I see the session, and there is a value for the login name. When run from SSMS the query has never shown this blank loginame, but I do track it when the query is run from Server Agent.
Does anyone have any idea how a session could legitimately show up in sysprocesses without a loginame? And if I don't see it in that column can I get it from somewhere else? (the case I know about is an SQL user)
Post #770214
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse