Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Get the DB Owner through T-SQL Expand / Collapse
Author
Message
Posted Wednesday, June 3, 2009 1:04 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, October 14, 2009 1:56 AM
Points: 438, Visits: 754
Hi All,

Is it possible to get who is created a database through T-SQL?

For Ex, if i see the Properties of a database there is a column called owner (who is created the database).

Likewise, through T-SQL is it possible to achieve the same owner?

Appreciate your help!!!

---
Post #727921
Posted Wednesday, June 3, 2009 1:15 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:13 AM
Points: 4,432, Visits: 4,167
sqluser (6/3/2009)
Hi All,

Is it possible to get who is created a database through T-SQL?

For Ex, if i see the Properties of a database there is a column called owner (who is created the database).

Likewise, through T-SQL is it possible to achieve the same owner?

Appreciate your help!!!

---

You can get the owner of the database by running sp_helpdb. But the owner is not necessarily the user who created the database. In fact on most of the databases I work with, we change the owner to sa.


Markus Bohse
Post #727927
Posted Wednesday, June 3, 2009 1:22 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, October 14, 2009 1:56 AM
Points: 438, Visits: 754
Thanks you very much MarkusB for your quick info.
Post #727931
Posted Wednesday, June 3, 2009 6:27 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, October 14, 2009 1:56 AM
Points: 438, Visits: 754
MarkusB,

Is it possible to achieve this through sql statement? Like sys.databases some thing like ....

---
Post #728090
Posted Wednesday, June 3, 2009 6:31 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 6:13 AM
Points: 4,432, Visits: 4,167
sqluser (6/3/2009)
MarkusB,

Is it possible to achieve this through sql statement? Like sys.databases some thing like ....

---

Is what possible?


Markus Bohse
Post #728097
Posted Wednesday, June 3, 2009 6:41 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:21 PM
Points: 5,975, Visits: 12,883
This gives the owner of the database

select suser_sname(sid),name from master..sysdatabases

just add the relevant where clause for a particular database

Retrieving who originally created the database (if different) I dont think can be done. If the owner has never been changed the above query will return the id the person who created the database was logged on with.


---------------------------------------------------------------------

Post #728106
Posted Wednesday, June 3, 2009 6:57 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, October 14, 2009 1:56 AM
Points: 438, Visits: 754
george sibbald (6/3/2009)
This gives the owner of the database

select suser_sname(sid),name from master..sysdatabases

just add the relevant where clause for a particular database

Retrieving who originally created the database (if different) I dont think can be done. If the owner has never been changed the above query will return the id the person who created the database was logged on with.


Thanks george... Very valuable information as per me.

Thanks...

---
Post #728129
Posted Friday, December 27, 2013 1:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, December 27, 2013 1:26 AM
Points: 2, Visits: 35
SELECT suser_sname( owner_sid ), * FROM sys.databases
Post #1526099
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse