Hello I'm trying to create a way in which I could track the number of times a certain column in a database table is selected. Is there something I could implement like a trigger that could increment a count column on another table that is associated with the selected row? Trying to figure out which rows in my database tables are used the most.

Thanks, any help is appreciated.

  • Are people writing queries into the database directly or are they accessing through a system that they input parameters and the actual work it all done behind the scenes? – Ste Bov Apr 18 '18 at 15:52
  • 2
    Which DBMS are you using? sql is a language, not a database management system. – Max Vernon Apr 18 '18 at 16:02

For SQL Server, you could set up an Audit as described in the documentation: SQL Server Audit (Database Engine).

All editions of SQL Server support server level audits. All editions support database level audits beginning with SQL Server 2016 (13.x) SP1. Prior to that, database level auditing was limited to Enterprise, Developer, and Evaluation editions.

See also Auditing SELECT statements in SQL Server 2008 by Sreekar Mankala.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.