Google Custom Search

Monday, December 3, 2007

List orphan IDs

This script displays the list of orphan SQL Server accounts from all the databases

Exec SP_MSForEachDB 'select ''?'' as DBName, name AS UserName, sid AS UserSID
from ?..sysusers
where issqluser = 1 and
(sid is not null and sid <> 0x0)
and suser_sname(sid) is null
order by name'

No comments: