sql - Listing database names from multiple databases that a user has access to -


i asked supervisor create ssrs report (using sql server 2008)that display database names user has access , making sure user still has active account. can query user names different databases can't seem list database names user has access to.

is there way achieve eventhough databases located in different linked server.

thank in advance, point me right direction highly appreciated.

declare @dbuser_table table (dbname varchar(200),          username varchar(250),          logintype varchar(500),          associatedrole varchar(200))  declare @username varchar(250)  set @username = 'dbo' --change desired username  set @dbuser_sql='select ''?'' dbname,a.name name,a.type_desc logintype,user_name(b.role_principal_id) associatedrole ?.sys.database_principals  left outer join ?.sys.database_role_members b on a.principal_id=b.member_principal_id  a.sid not in (0x01,0x00) , a.sid not null , a.type not in (''c'') , a.is_fixed_role <> 1 , a.name not ''##%'' , ''?'' not in (''master'',''msdb'',''model'',''tempdb'') order name'  insert @dbuser_table   exec sp_msforeachdb @command1=@dbuser_sql   select *    @dbuser_table   username = @username  order dbname  

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -