Re: Database Table usage
- From: "Uri Dimant" <urid@xxxxxxxxxxx>
- Date: Sat, 8 Aug 2009 15:14:05 +0300
Jack
This script I got from Dejan Sarka long time ago, try and see if it works
for you
For example, let's say we want to follow selects on the Customers table of
the Northwind database. Create a trace with only the following settings:
- SP:StmtCompleted and SQL: StmtCompleted events
- EventClass, TextData, ApplicationName and SPID columns
- DatabaseID Equals 6 (DB_ID() of the Northwind database) and
TextData Like select%customers% filters
- Name the trace SelectTrigger and save it to a table with the same
name in the Northwind database.
Start the trace, and create the following trigger using Query Analyzer:
CREATE TRIGGER TraceSelectTrigger ON SelectTrigger
FOR INSERT
AS
EXEC master.dbo.xp_logevent 60000, 'Select from Customers happened!',
warning
Now check how trigger works by performing couple of selects:
SELECT TOP 1 *
FROM Customers
SELECT TOP 1 *
FROM Orders
SELECT TOP 1 c.CustomerID
FROM Customers c INNER JOIN Orders o
ON c.CustomerID=o.CustomerID
With Event Viewer, check whether you got two warnings in the Application log
for the 1st and the 3rd queries (the 2nd should be filtered out).
"Jack Benny" <pkline_no_spam@xxxxxxxxxxxxxxxxxx> wrote in message
news:a7ho755ca8p0m5hi5hhvdmlutpirntbo0g@xxxxxxxxxx
Is there any way to track who accesses a particular table in a
database and when? We have a few tables in a database that we update
daily but we're not exactly sure anyone is still here using the
information. Is there some form of monitor I can set?
.
- References:
- Database Table usage
- From: Jack Benny
- Database Table usage
- Prev by Date: Re: import unknown formated txt file
- Next by Date: RE: import unknown formated txt file
- Previous by thread: Re: Database Table usage
- Index(es):
Relevant Pages
|
Loading