Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql query

Posted on 2015-01-20
2
Medium Priority
?
82 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

916 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