If you need to know which users exist in every database on your server (as apposed to server logins) you can use the undocumented stored procedure sp_msforeachdb as in the example below:
EXEC sp_msforeachdb 'USE [?];
SELECT
DB_NAME() As DBName
,name
FROM
sysusers
ORDER
BY name'
This piece of code is ideal for a Snippet.
Comments
Post a Comment