就我而言,我需要查看凭据的使用方式和位置,这不仅包括登录,还包括代理。我发现这两个查询一起给了我一个有用的概述:
SELECT c.credential_id, c.name AS Credential_Name, c.credential_identity, p.name AS Proxy_Name, p.enabled, p.description
FROM master.sys.credentials c
LEFT JOIN msdb..sysproxies p
ON c.credential_id = p.credential_id
SELECT c.credential_id, c.name AS Credential_Name, c.credential_identity, p.name AS Principal_Name, p.type_desc, p.is_disabled, p.default_database_name
FROM master.sys.credentials c
LEFT JOIN master.sys.server_principals p
ON c.credential_id = p.credential_id
在 SQL 2008 R2 到 2016 上进行了测试。