How can I tell when a SQL Server user last logged in?
Daniel Martin
Updated on March 05, 2026
- SELECT MAX(login_time) AS [Last Login Time], login_name [Login]
- FROM sys.dm_exec_sessions.
- GROUP BY login_name;
Then, how can I tell what users are logged into SQL Server?
You can use the Activity Monitor in SQL Server Management Studio. Once it's open look at the Processes section to see what is running, the login, database being used, and other helpful information.
One may also ask, how do you tell if a SQL database is being used? Another way to see if your database is in use is to look and see if the indexes are being used. Information on index usage is held in the sys. dm_db_index_usage_stats table since the last server reboot, and can be queried using this statement which can be tailored to select the data you need.
Similarly one may ask, how can I tell when a SQL Server database was last accessed?
Not easily, but if you turn on the logging feature of SQL Server you can examine the logs using software to discover when the last query was, and what it was. SQL Server can log event information for logon attempts and you can view it by reviewing the errorlog. By turning on the auditing level of SQL Server.
What is Accdate in Syslogins?
syslogins (Transact-SQL) - SQL Server | Microsoft Docs.
In this article.
| Column name | Data type | Description |
|---|---|---|
| accdate | datetime | Identified for informational purposes only. Not supported. Future compatibility is not guaranteed. |
Related Question Answers
How do I get a list of all SQL Server logins?
Answer: In SQL Server, there is a catalog view (ie: system view) called sys. sql_logins. You can run a query against this system view that returns all of the Logins that have been created in SQL Server as well as information about these Logins.How do I find my SQL Server username and password?
You can see the user mappings by opening Sql Server Management Studio and connecting to your server. In the Object Explorer area expand the Security and then Login folders (just under "Databases"). Double-click a login to open it's Properties window, and find the User Mappings section.How do you kill a connection in SQL Server?
SQL Server Management Studio Activity MonitorScroll down to the SPID of the process you would like to kill. Right click on that line and select 'Kill Process'. A popup window will open for you to confirm that you want to kill the process.
What is user in SQL Server?
A Login is an identity used to connect to a SQL Server instance. A User allows you to log into a SQL Server database and is mapped to a Login. So you will need to first create a Login, before you can create a User in SQL Server.How do I see who is logged onto a database in Access 2016?
To determine who is logged onto a database, follow these steps:- Open the sample database, Northwind.
- On the View menu, point to Database Objects, and then click Modules.
- Click New.
- Type or paste the following code:
- Save the module as ShowUsers.
- Press CTRL+G to open the Immediate Window.
How do I check SQL database activity?
How to start Activity Monitor- In the SQL Server Management Studio menu click Tools and then Options.
- Open the Environment | Start Up tab.
- Select the Open Object Explorer and Activity Monitor option.
How do I see recently updated tables in SQL Server?
If a user wants to find out when was the last table updated he can query dynamic management view (DMV) – sys. dm_db_index_usage_stats and easily figure out when was the table updated last.How can I tell if a SQL database is taken offline?
Who changed SQL Server database state to OFFLINE?- Connect to SQL Server → open SQL Server logs and scan through the logs. You will find entry like:
- Now go to Windows event viewer (under Administrative Tools) and open Application logs.
- Now we know the spid, timeframe when this change was made.
How do I find the database name in SQL Server?
To view a list of databases on an instance of SQL Server- In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
- To see a list of all databases on the instance, expand Databases.
How can check table usage in SQL Server?
Using SQL Server Management Studio- In Object Explorer, expand Databases, expand a database, and then expand Tables.
- Right-click a table, and then click View Dependencies.
- In the Object Dependencies<object name> dialog box, select either Objects that depend on <object name>, or Objects on which<object name>depends.
How can I tell if Oracle database is being used?
Checking the Database Instance Status- Log in to the database server as the oracle user (Oracle 11g server installation user).
- Run the sqlplus "/as sysdba" command to connect to the database.
- Run the select INSTANCE_NAME, STATUS from v$instance; command to check the status of database instances.
Can't restore because database is in use?
How to Fix 'can't restore SQL database because it is in use' Problem? When attempting to restore SQL Server db, make sure there are no active connections. If someone is using the database, the restore operation will fail. To resolve the issue, you will need to disconnect the active users.What is my current MySQL database?
The most common way to get a list of the MySQL databases is by using the mysql client to connect to the MySQL server and run the SHOW DATABASES command. If you haven't set a password for your MySQL user you can omit the -p switch.How do I find the size of a SQL Server database?
Using SQL Server Management Studio- In Object Explorer, connect to an instance of SQL Server and then expand that instance.
- Expand Databases.
- Right-click a database, point to Reports, point to Standard Reports,, and then click Disk Usage.