How can I query the list of database roles in a SQL Server 2000 database?

Warrior Bob picture Warrior Bob · Jan 3, 2013 · Viewed 34.3k times · Source

In Sql Server 2000, is it possible to return, via SQL query, a complete list of database roles that exist in a given database?

I know it is possible to see these roles by expanding the Security, Roles, and Database Roles nodes in SQL Server Management Studio, but I'd like to get them through a query that I can parse programmatically.

Screenshot of the nodes in question

To clarify, I'm not looking for a list of users with their roles, but just the list of roles themselves.

Answer

Laurence picture Laurence · Jan 3, 2013

Every database in SQL Server 2000 has a sysusers system table

Probably something like

Use <MyDatabase>

Select 
  [name]
From
  sysusers
Where
  issqlrole = 1

will do the trick