How To List All Logins In SQL Server

Published: 20 October 2022
on channel: MS SQL DBA Tech Support
2,025
17

select sp.name as login,
sp.type_desc as login_type,
sl.password_hash,
sp.create_date,
sp.modify_date,
case when sp.is_disabled = 1 then 'Disabled'
else 'Enabled' end as status
from sys.server_principals sp
left join sys.sql_logins sl
on sp.principal_id = sl.principal_id
where sp.type not in ('G', 'R','A','C','U')
order by sp.name;

====================
--Type of principal
S = SQL Server user
U = Windows user
G = Windows group
A = Application role
R = Database role
C = Certificate mapped
K = Asymmetric key mapped


Watch video How To List All Logins In SQL Server online, duration hours minute second in high quality that is uploaded to the channel MS SQL DBA Tech Support 20 October 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 2,025 times and liked it 17 visitors.