Posts

Showing posts from February, 2017

SQL Server Database Permission Scripts

#1 - Script to get list of all database name and its user in SQL Server USE MASTER   GO      SELECT  SL.dbname  AS   'Database Name' ,SL. name   AS   'User Name' ,SP.type_desc  AS   'Login Type' ,  SL.denylogin, SL.hasaccess, SL.isntname, SL.isntname, SL.isntgroup, SL.isntuser, SL.sysadmin,   SL.securityadmin, SL.serveradmin, SL.setupadmin, SL.processadmin, SL.diskadmin, SL.diskadmin,   SL.dbcreator, SL.bulkadmin  FROM  sys.server_principals  AS  SP   INNER   JOIN  sys.syslogins  AS  SL  ON  SP.SID = SL.SID   #2 - Script to get list of all database users and their roles in SQL Server Use Master   GO      exec  sp_msForEachDb ' use [?]   select  db_nam...