Link to home
Start Free TrialLog in
Avatar of tf842
tf842

asked on

How can I get all the user id's, NT Auth and SQL Auth used on a server by database

I have a SQL Server 2000.

I need to know how I can get all the user id's, both NT Auth and SQL Auth, so I can build an emailing list for process status notification.

Thank you,
Sami
Avatar of Einstine98
Einstine98

select * from sysusers
Avatar of tf842

ASKER

Do I have to query sysusers for each database on the server or is there a centralized table that will give me the userid and the databases they have permission to access?

I was hoping something could be queried from the Security.logins for the server and joined to the permissions so the permissions to the individual databases could be identified.

I apologize for this extension of the question, but I was in a hurry and submitted it too quickly. I will increase the points to 500 should the answer include this additional part of the question.

Sami

no worries...

sysusers is for each database... you can write a script to query all the databases for you

SELECT 'UNION SELECT * FROM [' + NAME + ']..sysusers'
FROM sysdatabases

copy the outcome, paste it in a new query, delete the first uninon and you have all the users in all databases...

you can then join it to

master..syslogins

ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tf842

ASKER

aneeshattingal,
I tried to make your code work to no avail. I can get a successful message if I run just:
exec sp_MSforeachDB 'use ?' ; (with the added tick after the ?

However, the balance of the query does not run properly with or without the above portion.

Any ideas?

Thank you,
Sami
you need to run the Query as it is no need to change, just copy paste and run