Skip to content

Instantly share code, notes, and snippets.

@nullbind
Last active February 13, 2017 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nullbind/c58e424d81f96efb3a2a360238021716 to your computer and use it in GitHub Desktop.
Save nullbind/c58e424d81f96efb3a2a360238021716 to your computer and use it in GitHub Desktop.
This script with enumerate all database users for the selected database. The SQL login must have a database user mapping or guest access. No other privileges are required.
select n [id], USER_NAME(n) [user_name]
from (
select top 10000 row_number() over(order by t1.number) as N
from master..spt_values t1
cross join master..spt_values t2
) a
where USER_NAME(n) is not null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment