Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > Databases > General SQL Server Support

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-07-2008, 09:10 PM
rcamarda
 
Posts: n/a
select blocking sessions t-sql

Is there a table or structure that contains information that I can see
via the Activity Monitor? I've searched the msdb database and I've not
found any tables that have what I am looking for.
I have tools in Cognos BI that can monitor tables, see changes and
then send email. I want to monitor for blocked processes then react to
them.
We have SQL Server 2005.
TIA
Reply With Quote
  #2 (permalink)  
Old 08-07-2008, 10:22 PM
Erland Sommarskog
 
Posts: n/a
Re: select blocking sessions t-sql

rcamarda (robert.a.camarda@gmail.com) writes:
> Is there a table or structure that contains information that I can see
> via the Activity Monitor? I've searched the msdb database and I've not
> found any tables that have what I am looking for.
> I have tools in Cognos BI that can monitor tables, see changes and
> then send email. I want to monitor for blocked processes then react to
> them.
> We have SQL Server 2005.


You can detect blocking through sys.dm_os_waiting_tasks. For instance
you could poll it once a minute or so, and if wait_duration_ms exceeds
a certain threshold *and* session_id is >= 51 *and* there is a
blocking_session_id <> session_id, you could send an alert or whatever.
You probably have to test to see that you don't get too many false alarms.

You may also be interested at looking at my beta_lockinfo,
http://www.sommarskog.se/sqlutil/beta_lockinfo.html.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #3 (permalink)  
Old 08-08-2008, 01:55 PM
rcamarda
 
Posts: n/a
Re: select blocking sessions t-sql

>
> You can detect blocking through sys.dm_os_waiting_tasks. For instance
> you could poll it once a minute or so, and if wait_duration_ms exceeds
> a certain threshold *and* session_id is >= 51 *and* there is a
> blocking_session_id <> session_id, you could send an alert or whatever.
> You probably have to test to see that you don't get too many false alarms.
>
> You may also be interested at looking at my beta_lockinfo,http://www.sommarskog.se/sqlutil/beta_lockinfo.html.
>
> --
> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se


Thanks Erland, it is perfect for 2005!
Now, I need same thing for SQL Server 2000. As far as I can tell there
sys.dm_os_waiting_tasks doesnt exist in 2000.
Can you help one more time?
(BTW, what key words could I use to search? JOBS and TABLE mostly got
hits on emploment opportunities)
TIA
Reply With Quote
  #4 (permalink)  
Old 08-08-2008, 10:28 PM
Erland Sommarskog
 
Posts: n/a
Re: select blocking sessions t-sql

rcamarda (robert.a.camarda@gmail.com) writes:
> Thanks Erland, it is perfect for 2005!
> Now, I need same thing for SQL Server 2000. As far as I can tell there
> sys.dm_os_waiting_tasks doesnt exist in 2000.
> Can you help one more time?


The best bet in SQL 2000 is the column master.dbo.sysprocesses.blocked.

My old aba_lockinfo runs on SQL 2000:
http://www.sommarskog.se/sqlutil/aba_lockinfo.html.

> (BTW, what key words could I use to search? JOBS and TABLE mostly got
> hits on emploment opportunities)


Search for what? I'm pretty bad at searching myself. But if you mean
SQL Server jobs, I guess it helps putting in "Agent". And "SQL Server"
of course.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #5 (permalink)  
Old 08-10-2008, 07:48 PM
Erland Sommarskog
 
Posts: n/a
Re: select blocking sessions t-sql

rcamarda (robert.a.camarda@gmail.com) writes:
> Is there a table or structure that contains information that I can see
> via the Activity Monitor? I've searched the msdb database and I've not
> found any tables that have what I am looking for.
> I have tools in Cognos BI that can monitor tables, see changes and
> then send email. I want to monitor for blocked processes then react to
> them.
> We have SQL Server 2005.


Also, this blog post from SQL Server MVP Tony Rogerson can be useful:
http://sqlblogcasts.com/blogs/tonyro...e-it-work.aspx

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > Databases > General SQL Server Support


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:10 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Loans | Gas Suppliers | Credit Cards | Mortgages | Cheap Loan



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114