Monday, February 13, 2017

vwAdmin_DB_List

CREATE VIEW [dbo].[vwAdmin_DB_List]
AS


SELECT
sd.[name] AS 'DBName'
, SUBSTRING(SUSER_SNAME(sd.[owner_sid]), 1, 24) AS 'Owner'
FROM
master.sys.databases sd
WHERE
HAS_DBACCESS(sd.[name]) = 1
AND sd.[is_read_only] = 0
AND sd.[state_desc] = 'ONLINE'
AND sd.[user_access_desc] = 'MULTI_USER'
AND sd.[is_in_standby] = 0

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home