SQL Tip & Tricks

January 13, 2021
sql t&t

Things I do not want to forget and search here is easier than searching Google with Bing

 

 

FOR EACH DB:

 

exec sp_MSforeachdb '

 

IF(''?'' NOT IN (''master'',''tempdb'',''model'',''msdb'',''distribution'',''redgate''))

BEGIN

USE ?

select ''?''

exec sp_helpuser

 

--select ''?'', user_name(grantee_principal_id) as usrname, type,permission_name,state_desc  from sys.database_permissions where user_name(grantee_principal_id) not in (''public'',''dbo'',''guest'') and user_name(grantee_principal_id) not like ''%##%''

 

END

 

 

'