Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Finding the user who created the Database

Author  Topic 

dolphin123
Yak Posting Veteran

84 Posts

Posted - 2012-07-17 : 16:15:27
Hi,

I wrote this query to find the users who created the databases on an instance, but I am getting the wrong user IDs such as dbo.

I like to know the user as in "Security - logins". How can I find that out?

SELECT sd.sid,sd.name,sd.crdate, su.name
FROM master..sysdatabases sd
inner join master..sysusers su on sd.sid = su.sid

Also, if a user logged in using the windows security (that is "domainname\username", is there any way to list that one?

Appreciated in advance.

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2012-07-18 : 05:16:20
SELECT sd.name,sd.create_date, su.name
FROM sys.databases sd
left outer join master..syslogins su on sd.owner_sid = su.sid

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

dolphin123
Yak Posting Veteran

84 Posts

Posted - 2012-07-18 : 13:10:17
Thanks a lot
Go to Top of Page
   

- Advertisement -