Showing posts with label Database User. Show all posts
Showing posts with label Database User. Show all posts

Wednesday, July 27, 2011

list database users in sql server database

it can be found from sys.database_principals or sysusers table.

one example to build SQL by using it.

select 'sp_change_users_login ''auto_fix'','+name+',null,null' from sys.database_principals where type='S' and default_schema_name not in ('dbo','guest') and default_schema_name is not null