我想創建一個查詢,列出允許特定用戶讀取和寫入的所有數據庫名稱。查找數據庫,其中特定用戶是db_owner和db_datawriter
我能夠找到如何列出所有的數據庫名稱,但我不知道該如何檢查上述條件。
SELECT name
FROM master.sys.databases
如何檢查特定用戶是否被允許在數據庫中讀寫?
這裏是我想要的東西爲例:
I have 3 database : First,Second and Third. my users are Alex and John.
Alex is allowed to write and read in the First and Second database
and John is allowed to write and read in the Second and the Third database.
What i want now, is to know in which databases Alex is allowed to write and read
and I need the name of the databases as result of the query
This [link](http://invalidlogic.com/2007/03/04/sql-server-tip-how-to-find-the-owner-of-a-database-through-t-sql/ ) 可能有幫助。如果確實如此,您可以將其作爲答案發布(經過一段時間後)。 –