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
 General SQL Server Forums
 New to SQL Server Programming
 Find all DBOs

Author  Topic 

devils3cups
Starting Member

23 Posts

Posted - 2008-05-15 : 11:39:15
I'm trying to find all the users in a db that have the dbo role.
I looked under the sysusers table and noticed a role column and for this db and all of the dbos have the same role 0x01. There would be no reason for a person to have more then one role if their already a dbo right? So, if a person is a dbo their role should just be 0x01?

One last thing. I noticed that when I query for "Select * from sysusers where role = '0x01'" it pulls back no result when its obviously there. It must because its a binary type. How would I modify this select statement then?

Thanks for the help!

reneesherry
Starting Member

1 Post

Posted - 2008-05-15 : 11:54:07
Most of our users have dbo and public roles. I do not see any drawback in having additional roles, so I would not worry about it.

April/ www.infosaic.com
Go to Top of Page

devils3cups
Starting Member

23 Posts

Posted - 2008-05-15 : 11:56:37
quote:
Originally posted by reneesherry

Most of our users have dbo and public roles. I do not see any drawback in having additional roles, so I would not worry about it.

April/ www.infosaic.com



Maybe I'm not stating my question correctly. I'm just trying to find all the dbo users in a db. I was just going through some of my logic on how I was trying to obtain that information.
Go to Top of Page

devils3cups
Starting Member

23 Posts

Posted - 2008-05-15 : 16:10:15
Bump.
Any one?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-15 : 18:31:00
It is very rare that you have to query the system tables directly. Always check if there is a view or stored procedure instead.

For your issue, you can use:
EXEC sp_helprolemember 'db_owner'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-05-16 : 02:09:15
why dont you use sp_who? or sp_who2

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

devils3cups
Starting Member

23 Posts

Posted - 2008-05-16 : 09:49:01
quote:
Originally posted by tkizer

It is very rare that you have to query the system tables directly. Always check if there is a view or stored procedure instead.

For your issue, you can use:
EXEC sp_helprolemember 'db_owner'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx



Thanks, sp_helprolemember was exactly what I needed!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-16 : 11:11:51
quote:
Originally posted by sunsanvin

why dont you use sp_who? or sp_who2



That will not work for this problem.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page
   

- Advertisement -