Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

sql query

Posted on 2015-01-20
2
75 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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