Solved

sql query

Posted on 2015-01-20
2
73 Views
Last Modified: 2015-01-27
I need a query that will give me the last login time for all databases within an instance of sql and also give me database name and only one entry per database.

Thanks!
0
Comment
Question by:jamesmetcalf74
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40560218
login time is per LOGIN, not per database. within a session, you can then use any of the databases in that instance (given the permissions being granted to the LOGIN via either server roles or via the mapped USER in the relevant databases)
hence, in short, a login time per database is not possible.

next, the login audits are not inside the sql server, but in nt event log, and requires the login success event to be configured on the instance level. still, in the end, this will not be a SQL query, but a request to the windows event log, unless you export that one into a sql table.

another option is that any application that is doing the login is running a "log this login" procedure that stored the information then in a central table. to be implemented... could eventually be a instance wide logon trigger  (see here: http://msdn.microsoft.com/en-us/library/bb326598.aspx)

in short, the answer is: you cannot do it.
long answer: you can implement this , based on your requirements
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 40560617
do you actually mean a user login  to a database , or are you attempting to determine when databases where "last used"...
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Join vs where 2 38
Trouble viewing a table in a database. SSMS 2008 R2 4 31
SQL Statement to Update Email Domain 2 24
sql query questions 2 26
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now