Home All Groups Group Topic Archive Search About

who or what is accessing my table?

Author
9 Feb 2007 9:37 PM
jmelkerson
I have a situation where records are mysteriously disappearing from a table. 
How can I monitor the table to discover who or what is accessing it or
executing statements or stored procedures on it?  I have tried SQL Profiler
but don't know how to filter properly.

Author
9 Feb 2007 11:21 PM
AlterEgo
j,

You probably should spend more time to learn Profiler. You could put a
delete trigger on the table and write to an audit table - this is more
complex than learning Profiler.

-- Bill

Show quote
"jmelkerson" <jmelker***@discussions.microsoft.com> wrote in message
news:6BAC1023-805E-4AC4-BE1C-006F8F67ECBA@microsoft.com...
>I have a situation where records are mysteriously disappearing from a
>table.
> How can I monitor the table to discover who or what is accessing it or
> executing statements or stored procedures on it?  I have tried SQL
> Profiler
> but don't know how to filter properly.
Author
10 Feb 2007 12:49 AM
Hari Prasad
Hello,

Follow the steps:-

1. Open Profiler and trace the events

    "RPC: SP:Completed "
   "SP:Completed "
2. Run this events for the doubtful time

3. Stop and Save the profiler trace output into a table

4. Query trace table based on TEXTDATA column

Thanks
Hari



Show quote
"jmelkerson" <jmelker***@discussions.microsoft.com> wrote in message
news:6BAC1023-805E-4AC4-BE1C-006F8F67ECBA@microsoft.com...
>I have a situation where records are mysteriously disappearing from a
>table.
> How can I monitor the table to discover who or what is accessing it or
> executing statements or stored procedures on it?  I have tried SQL
> Profiler
> but don't know how to filter properly.
Author
10 Feb 2007 5:06 PM
Erland Sommarskog
jmelkerson (jmelker***@discussions.microsoft.com) writes:
> I have a situation where records are mysteriously disappearing from a
> table.  How can I monitor the table to discover who or what is accessing
> it or executing statements or stored procedures on it?  I have tried SQL
> Profiler but don't know how to filter properly. 

First of all, which version of SQL Server?

A good trace would be one that includs the events TSQL:StmtCompleted and
SP:StmtCompleted with a filter on textdata that includes the table
name, for instance '%DELETE%mytable%'.

While you can use Profiler to set up the trace, it's better to save the
trace as a script, and then run the trace as a server-side trace to a file.
This takes less resources. You can then use fn_trace_gettable to read the
file.

I don't know you think that you are missing rows, but sometimes the cause
for missing rows is that the transaction that inserts the rows is rollbacked
unexpectedly. This you cannot see in a trace. Then again, if you run a
trace for 24 hours, and you miss rows at this point but the trace is empty,
this is a strong indication of a rollback problem.

--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

AddThis Social Bookmark Button