Re: i would like to see who executed a select statement on a specific table
- From: "Uri Dimant" <urid@xxxxxxxxxxx>
- Date: Sun, 16 Mar 2008 11:57:19 +0200
Profiler...
See an example written by Dejan Sarka some time ago.
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).
"Ziver MALHASOÐLU" <zam@xxxxxxxxxx> wrote in message
news:%2305kvOqhIHA.5088@xxxxxxxxxxxxxxxxxxxxxxx
Hello,
Is there a way to log executed select statements for a specific table in
sql server 2005?
If there is, how?
Regards,
Ziver
.
- References:
- i would like to see who executed a select statement on a specific table
- From: Ziver MALHASOŠLU
- i would like to see who executed a select statement on a specific table
- Prev by Date: Re: Setting up a new database for application
- Next by Date: Re: ALTER TABLE TableName DISABLE TRIGGER error
- Previous by thread: i would like to see who executed a select statement on a specific table
- Next by thread: how to log executed select statements for a specific table
- Index(es):
Relevant Pages
|