SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Finding the user who created the Database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dolphin123
Starting Member

USA
44 Posts

Posted - 07/17/2012 :  16:15:27  Show Profile  Reply with Quote
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

Pakistan
864 Posts

Posted - 07/18/2012 :  05:16:20  Show Profile  Visit lionofdezert's Homepage  Send lionofdezert a Yahoo! Message  Reply with Quote
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
Starting Member

USA
44 Posts

Posted - 07/18/2012 :  13:10:17  Show Profile  Reply with Quote
Thanks a lot
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000