How do you check the history of a user in MSSQL?


  • QA Engineer

    I created a user and I would like to know the history of the stored_procedures he manually ran and the SQL queries he executed, how do you do that? Is this possible in MSSQL?



  • What you're looking for is a feature called https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine?view=sql-server-ver15 which allows you to specify a number of events that get logged, including who runs which stores procedures and queries. I believe specifically you'll want to enable the database audit in the specific databases you want to log, when you care about those kinds of events.

    The catch is you have to enable and configure it first, as it's not on by default. Also please note auditing features of SQL Server do add some overhead to resource consumption, especially with the more events you setup to be audited.

    Please also see https://www.sqlshack.com/a-quick-overview-of-database-audit-in-sql/ for further information and overview on how it works.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2