I need to check whether a user is db owner.
I've found two methods:
- look at "exec sp_helprolemember" output table
- select count(*) from (select DbRole = g.name, MemberName = u.name, MemberSID = u.sid from sys.database_principals u, sys.database_principals g, sys.database_role_members m where g.principal_id = m.role_principal_id and u.principal_id = m.member_principal_id and g.name='db_owner') output where MemberName='user_to_be_checked'
Which is, in your opinion, the most long term supported method? I mean: will it be more likely for Microsoft to commit design changes to system tables structures or stored procedures syntax/output? And which one is the most portable across SQL Server versions?
Thnx
Raf