| Login

Search this Blog


Links I like to keep around




Here are the most recent postings to this blog. Use the archive calendar or search to find other entries.
Jun13

Written by:R Teachout
6/13/2007 10:24 PM

This was found by a friend, so I can't take credit, but I wanted to post it for others.  He found it an issue to open Mangement->Current Activity on SQL2000 because he received a number of errors since current activity by default returns all databases, and he doesn't have permission to the other databases, but he only wanted his database in the result.

Here's what he found:

The core of the current activity view seems to be the process sp_MSset_current_activity.  There are two queries in this procedure that hit tables in master (one on syslockinfo and one on sysprocesses).  By adding where clauses (where rsc_dbid = DB_ID() and where dbid = DB_ID() respectively) to those queries, you can limit the results to just the database where you create your custom procedure (mine is sp_my_set_current_activity).  (This would be a copy of sp_MSset_current_activity from the master db)

sp_my_set_current_activity returns a value called spid. 

After you run sp_set_my_current_activity, you run sp_MSget_current_activity @id=###, @option=1 (where ### is the value returned from sp_set_my_current_activity) to get the results that are normally shown in Management->Current Activity, but limited to only the current database the sp_my_set_current_activity is located in.

Note: All of these are executed by the DBO user of your database, not as SYSADMIN!

Great Notes!!!  Use at your own risk!

Tags:

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel  

The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency. The second is that automation applied to an inefficient operation will magnify the inefficiency.
-Bill Gates

Inspired by Nina