Sql-server – Investigating specific SELECT queries

auditlogsql server

For a particular row in a table how can I determine the number of reads done to it such as

SELECT * FROM MyTable WHERE ID = <something>

and when and where the read query executed?

I'm investigating a product that was "LOST" in a small company. So I wanted to see if anybody looked it up before it disappeared.

Best Answer

There is nothing native in SQL Server that is going to track that level of information. Based on what version of SQL Server you are using there is SQL Server Audit (SQL Server 2008 or higher) that can track database level access, but it does require Enterprise Edition.

You could also roll out your own method of logging using Profiler or Extended Events that just capture object access for a given database. As long as you are not trying to capture the query and all it should be pretty low overhead, but it would be based on how active your system is.