Sunday, February 26, 2012

Find Database Users

I'm wondering if there is a way I can query against a
system table to find out all the users on a server and
what permissions they all have? If anyone has any ideas I
would really appreciate it! Thanks!Ann
Aaron Bertrand wrote
This will only cover those who have
been explicitly given access to the procs using GRANT.
DECLARE @.username VARCHAR(32)
SELECT @.username = '?'
SELECT o.name, CanExec = CASE WHEN p.id = o.id THEN 'Yes' ELSE 'No' END
FROM sysobjects o LEFT OUTER JOIN syspermissions p
ON o.id = p.id
AND p.grantee = USER_ID(@.username)
"Ann" <ao_949@.hotmail.com> wrote in message
news:127901c4f519$8e655690$a401280a@.phx.gbl...
> I'm wondering if there is a way I can query against a
> system table to find out all the users on a server and
> what permissions they all have? If anyone has any ideas I
> would really appreciate it! Thanks!
>

No comments:

Post a Comment