Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 How to get all roles in all databases

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-11-29 : 08:25:12
Sudhakar writes "Hi team members,

we have sp_databases for get all databases.Same as can we get all roles and role information in all databases ???
or else any sp avail ???

Thanking u.

Bye
Sudhakar"

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2004-11-30 : 01:07:08
[code]
create table #temp (dB_name sysname, RoleName sysname, RoleId smallint, IsAppRole int)
insert into #temp
EXEC sp_MSforeachdb @command1='use ? select db_name(), name, uid, isapprole from sysusers where issqlrole = 1 or isapprole = 1'

select * from #temp
[/code]

Note. sp_MSforeachdb is an undocumented feature and would not guarentee it would be future versions of SQL Server.

Hemanth Gorijala
Exchange a Dollar, we still have ONE each._______Exchange an Idea, we both have TWO each.
Go to Top of Page
   

- Advertisement -