New answers tagged

2

I'd like to answer to your second question, maybe you'll change your idea of dropping not mapped logins. here I would like to check if the login has any database users in other databases and if not drop login USE [master] GO DROP LOGIN [username] GO This approach can grant access to some login, in contrary as you think. In many organizations Windows groups ...


3

use this query: IF OBJECT_ID(N'tempdb..#results', 'U') IS NOT NULL DROP TABLE #results; CREATE TABLE #results( LoginName sysname ,LoginType nvarchar(60) ,IsMustChange bit ,DatabaseName sysname NULL ,DatabaseUserName sysname NULL ,DatabaseRoleName sysname NULL ); EXEC sp_MSforeachdb ' USE [?]; INSERT INTO #results SELECT ...


Top 50 recent answers are included