Site icon Database Tutorials

How To Find Unused Indexes in SQL Server

Each database administrator wants to detect and delete unused logins. By default in SQL Server, the last time the login was logged is not stored in a table or dmw. To meet this need, we will use the following script.

First of all, you should create a table in any database with the following script. I chose the master database, because its my local PC. You should create another database for this in your environement. In this table we will store the name of the login and the date of the last login.

You can create the above script as a job that runs at 1 minute intervals. You can then use the following script to query which login is active and which login is not used.

Exit mobile version