Question

I am aware of how to find info on current sessions and their users (sp_who2, sp_WhoIsActive, ...)

How can I retrieve such info for the past? I could not find info on that. Simply put, my question is:

  • Who was logged in?
  • From when to when?
  • What did he do?
  • (Additionally: info on processes/resource usage/waits/locks would be nice)

Is this information logged at all? If so, how is it queried? If not, what is best practise to build such logging?

I am on SQL Server 2008 R2 (SP1) Standard Edition.

EDIT: added version info and tag.

Was it helpful?

Solution

This data is not logged by default, you will have to set up auditing.

Auditing an instance of the SQL Server Database Engine or an individual database involves tracking and logging events that occur on the Database Engine. SQL Server audit lets you create server audits, which can contain server audit specifications for server level events, and database audit specifications for database level events. Audited events can be written to the event logs or to audit files.

Here's a how-to on setting it up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top