tags:

views:

55

answers:

4

I took over someones job and need to find out from where certain tables are being read. Is there a way to do that? The more information I could get about the caller the better.

I am using MS SQL Server 2000.

A: 

If you can get on the server while your table is being accessed, look into the undocumented stored procedure sp_who2.

Michael Petrotta
I dont know when the table is being accessed.
vikasde
A: 

You might also run a network sniffer process to watch the raw connections.

Alex Howansky
+1  A: 

You could add a trigger to the table you want to be audited and insert relevant data into an audit table from there.

E.g. http://www.devx.com/dbzone/Article/7939/1954

krock
Good practice for all sensitive tables.
Michael Petrotta
Triggers won't help if the OP wants to track tables "being read", which I assume means tracking SELECT statements. For that, you need a trace.
Pondlife
+2  A: 

If you want to see the full detail of all queries that are being run against the server, including the hostname and username of the client calling it, you'll want to run a trace.

You can use the SQL Profiler tool to run a short trace, but I prefer to run a "server-side" trace to a file, which I can examine later.

See the SQLServerPedia article here: http://sqlserverpedia.com/wiki/The_Server-side_Trace:_What,_Why,_and_How

BradC