TIL - July 25 2016

Jul 25, 08:32 AM

A great little built in stored procedure to map server level logins to database users named sp_msloginmappings .
if object_id('tempdb..#login_map') is not null 
	drop table #login_map

create table #login_map 
( 
	LoginName nvarchar(max)
	, DBName nvarchar(max)
	, UserName nvarchar(max)
	, AliasName nvarchar(max)
)

insert #login_map ( LoginName, DBName, UserName, AliasName )
EXEC master..sp_msloginmappings 

select *
from #login_map
Enjoy!
Constantine Kokkinos

,

---
---