Re: i would like to see who executed a select statement on a specific table



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



.



Relevant Pages

  • Re: SQL 2005 - audit SELECT statements?
    ... name in the Northwind database. ... Start the trace, and create the following trigger using Query Analyzer: ... FROM Customers ...
    (microsoft.public.sqlserver.security)
  • Re: Why cant i find a row in a dataset?
    ... > Currently had a Dataset that has information from the Northwind database, ... > Customers table in it. ... why when I enter ALFKI in txtCustomerID.Text is it not ... > Paul Custance ...
    (microsoft.public.dotnet.framework)
  • Re: Linq Sum() Question
    ... I made a console application that makes use of Northwind database. ... Made a dbml file of the database whith the designer and now I want to ... see the total of all orders of the customers. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Coding file into 4ths
    ... Customers in the Northwind database based on their customer id: ... MS Access MVP ... >> HTH, ...
    (microsoft.public.access.queries)
  • Re: Should be simple but....
    ... FROM Customers C ... INNER JOIN ORDERS O ... INNER JOIN [ORDER DETAILS] OD ...
    (microsoft.public.sqlserver.programming)