Solved

SQL sys.sysprocesses

Posted on 2012-03-28
3
434 Views
Last Modified: 2013-02-15
Hello
We have a process to monitoring the access to database.
Why exist processes without query command (sys.dm_exec_sql_text) that sql_handle value of the sys.sysprocesses is 0x000000000000000000000000000000000000000000000000 ?
What types of access are?
0
Comment
Question by:Jaimesastre
  • 2
3 Comments
 
LVL 40

Expert Comment

by:lcohan
ID: 37778936
That is the query handle like:


sql_handle
 

binary(20)
 

Represents the currently executing batch or object.

Note   This value is derived from the batch or memory address of the object. This value is not calculated by using the SQL Server hash-based algorithm.
 
http://msdn.microsoft.com/en-us/library/ms179881.aspx

You need a cross apply to find the actual statement if that's what you need.
0
 

Author Comment

by:Jaimesastre
ID: 37780676
Thanks.

We need know in real time all runing  process in the sql server with the query sys.sysprocesses.

We can know what is the query or process description of the row with SQL_Handle value 0x000000000000000000000000000000000000000000000000.

Is possible know it?

Regards
0
 
LVL 40

Accepted Solution

by:
lcohan earned 500 total points
ID: 37806340
You need to run a query like below to get all details and you could include a where clause as well:



SELECT
      BatchText            = SQLText.text ,
      BatchPlan            = QueryPlan.query_plan ,
      ExecutionCount      = CachedPlans.usecounts ,
      ObjectType            = CachedPlans.objtype ,
      Size_KB                  = CachedPlans.size_in_bytes / 1024
FROM
      sys.dm_exec_cached_plans AS CachedPlans
CROSS APPLY
      sys.dm_exec_query_plan (CachedPlans.plan_handle) AS QueryPlan
CROSS APPLY
      sys.dm_exec_sql_text (CachedPlans.plan_handle) AS SQLText
--WHERE ....
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
replicated - directional or bidirectional? 3 40
SSRS 2013 - Overlapping reports 2 38
sql 2016 data tools breakdown.. 1 25
SQL Recursion schedule 13 34
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question