Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 User Application Statistics

Author  Topic 

buzby
Starting Member

1 Post

Posted - 2014-07-16 : 09:43:50
I have an application audit table (e.g. audit_log) which records the following information :

user_id row_creation action

20039 2014-05-15 13:09:20.000 20
20048 2014-05-15 13:15:22.550 20
20039 2014-05-15 13:30:33.540 21
20048 2014-05-15 15:44:14.747 21
20048 2014-05-16 08:10:27.523 20
20048 2014-05-16 08:39:21.187 21
20048 2014-05-19 08:22:54.920 20
20048 2014-05-19 08:24:06.597 21
20048 2014-05-19 09:42:34.907 20
20048 2014-05-19 10:23:19.090 21

where action is defined :
20 = login
21 = logout

How can I query the table for following management information (in SQL SERVER 2008)?

1. Last user login?
2. How long(i.e. duration) user has been online for the day?
3. How many times user has login or logout per day?
4. which users logged into system on certain day?
5. Which users still logged in after 11pm?
6. Any other statistic that could be useful to management?

Any help would be much appreciated.

kind regards,
Buzby

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-16 : 12:25:08
http://www.sqlservercentral.com/articles/Best+Practices/61537/

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -