Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I mimic sp_who2 with SQL Server 2005s new dynamic management views?

0
10 Posted

How do I mimic sp_who2 with SQL Server 2005s new dynamic management views?

0

sp_who2 is a useful tool in learning about the current activity in SQL Server. However, there are some flaws in the design, including using (NOLOCK) on virtual tables (which is harmless but useless), ignoring the @loginame parameter when it is neither ‘active’ nor NULL, and relying on soon-to-be-deprecated objects like sysprocesses and syslockinfo. Someone at Microsoft tasked the MVPs with replicating sp_who2 in SQL Server 2005, using only the dynamic management views — and, in particular, staying away from sysprocesses. I managed to whip something up quickly, with a few caveats. I did not bother replicating the @loginame functionality in this version, because Microsoft’s version doesn’t work either. Also, there are a few pieces of information that are simply not available in the new DMVs, for example commands with values ‘AWAITING COMMAND’ and ‘UNKNOWN TOKEN’ are nowhere to be found. Finally, some metrics for tasks like ‘LOG WRITER’ and ‘CHECKPOINT’ seem to be missing, or I just don’t

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.