Server LogIn's without db roles



I want to write some role management views.

The first view would show all the roles a user is in on the server.
The second view would show all users who have server login but no
roles

Is there a slick way in 05 to join the databases on the server into a
view. I see there is now a sys.databases view which has a database_id
field. I was hoping to use only system views and avoid cursors or
undocumented stored procedures (sp_MSforeachdb).

If I have to use cursors would it be better to do my own with
sys.databases or use sp_MSforeachdb?

This is what I have so far

SELECT p. principal_id , p. name , r. role_principal_id ,p.sid,
( SELECT name FROM sys.database_principals
WHERE ( principal_id = r. role_principal_id )) AS
RoleName
FROM sys.database_principals AS p INNER JOIN
sys.database_role_members AS r
ON p. principal_id = r. member_principal_id
WHERE ( p . type = 'U' ) AND
( p . is_fixed_role = 0) AND
( p . name <> N'public' )



p.s.
Does sys.spMSforeachdb not work for databases that are ReadOnly and
being used?

/* If it's a single user db and there's an entry for it in
sysprocesses who isn't us, we can't use it. */
/* Create the select */
exec(N'declare hCForEachDatabase cursor global for select name
from master.dbo.sysdatabases d ' +
N' where (d.status & ' + @inaccessible + N' =
0)' +
N' and (DATABASEPROPERTY(d.name,
''issingleuser'') = 0 and (has_dbaccess(d.name) = 1))' )
.



Relevant Pages

  • Re: AS2005 ... what is wrong with it?
    ... What I have seen is that the dev server is *faster* than the prod server ... And does your dev server also have all 6 databases with all these roles? ... When I restore the "PROV" i got approx 20 sec. ... Starting from an empty data folder should show if this theory is true ...
    (microsoft.public.sqlserver.olap)
  • 2nd Post - Trouble Getting VS.Net 2003 WalkThrough working
    ... the server. ... MSDE either from the Setup or from the SQL2KDeskSP3 execute. ... it does look like some of the sample databases have been ... >> and they directed me to install MSDE and they attached a ConfigSamples ...
    (microsoft.public.sqlserver.msde)
  • RE: Server Explorer & Databases
    ... As for the visual studio's database server explorer, ... oracle, visual studio generally use the OLD DB provider which is for Oracle ... and support of most general funcctionalitis in latest version of Oracle. ... #Server Explorer for Oracle Databases ...
    (microsoft.public.vsnet.ide)
  • Re: 2nd Post - Trouble Getting VS.Net 2003 WalkThrough working
    ... The fact that the other databases exists phyiscally doesn´t mean that they ... can try to connect to SQL Server using OSL or a GUI. ... The Command OSQL ist for the commandline under DOS. ... > this MSDE either from the Setup or from the SQL2KDeskSP3 execute. ...
    (microsoft.public.sqlserver.msde)
  • Re: AS2005 ... what is wrong with it?
    ... I have 6 OLAP databases on the server. ... When I restore the "PROV" i got approx 20 sec. ...
    (microsoft.public.sqlserver.olap)