set nocount on select cast(@@servername as varchar(30)) [Server] exec sp_msforeachdb 'use ? if db_name() not in (''master'',''model'',''msdb'',''tempdb'') and exists (select 1 from sysprotects p join master.dbo.spt_values v on p.action = v.number where objectproperty(p.id,''IsUSerTable'') = 1 and p.id > 100 and p.protecttype = 205 -- grant and v.Type = ''T'' and v.name not in (''select'',''references'') and object_name(p.id) not in (''dtproperties'')) begin select cast(db_name() as varchar(30)) [Database] select cast(object_name(p.id) as varchar(40)) [Table] , cast(user_name(p.uid) as varchar(30)) [User or Role] , v.name [permission] from sysprotects p join master.dbo.spt_values v on p.action = v.number where objectproperty(p.id,''IsUSerTable'') = 1 and p.id > 100 and p.protecttype = 205 -- grant and v.Type = ''T'' and v.name not in (''select'',''references'') and object_name(p.id) not in (''dtproperties'') end'