-2

I need to find the last time a user accessed the database. I am new to SQL and rarely have to use it. Details would help or links to learn those details.

2
  • 2
    The options and syntax change with the type and version of the database. What type (MS SQL, Oracle, Postgres, etc) and version are you using? – kevinsky May 28 '19 at 17:25
  • MS SQL Microsoft SQL Server Management Studio 14.0.17254.0 Microsoft Analysis Services Client Tools 14.0.1016.251 Microsoft Data Access Components (MDAC) 10.0.14393.0 Microsoft MSXML 3.0 6.0 Microsoft Internet Explorer 9.11.14393.0 Microsoft .NET Framework 4.0.30319.42000 Operating System 6.3.14393 – Patti Robinson May 29 '19 at 18:04
0

For MS SQL server logins are not automatically tracked but this can be easily enabled with the Common Criteria Compliance option.

From the link you would run this

sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE;  
GO  
sp_configure 'common criteria compliance enabled', 1;  
GO  
RECONFIGURE WITH OVERRIDE; 
GO

Then restart the database and run the scripts here from Microsoft.

The logins can be accessed with this query

Select * from sys.dm_exec_sessions

You need elevated permissions (View Server State or higher) to query this table.

0

Short answer, most default configurations do not track successful SQL access.

There are a bunch of ways that you can start tracking, (based on your configuration, as mentioned by @kevinsky in the comments.)

You can look into to those to see if any have been implemented. If not...

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