Who is accesing my sql table?
I took over someones job and need to find out from where ce开发者_如何学编程rtain 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.
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
You might also run a network sniffer process to watch the raw connections.
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
If you can get on the server while your table is being accessed, look into the undocumented stored procedure sp_who2
.
精彩评论