Solved

sql query

Posted on 2015-01-20
2
77 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
[X]
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
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
     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 …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

728 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