Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Get the DB Owner through T-SQL


Get the DB Owner through T-SQL

Author
Message
SqlUser-529296
SqlUser-529296
SSC-Addicted
SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)

Group: General Forum Members
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!!!

---
MarkusB
MarkusB
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4449 Visits: 4208
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
SqlUser-529296
SqlUser-529296
SSC-Addicted
SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)

Group: General Forum Members
Points: 438 Visits: 754
Thanks you very much MarkusB for your quick info. :-)
SqlUser-529296
SqlUser-529296
SSC-Addicted
SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)

Group: General Forum Members
Points: 438 Visits: 754
MarkusB,

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

---
MarkusB
MarkusB
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4449 Visits: 4208
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
george sibbald
george sibbald
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6334 Visits: 13687
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.

---------------------------------------------------------------------
SqlUser-529296
SqlUser-529296
SSC-Addicted
SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)

Group: General Forum Members
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...

---
dkamalkumardba
dkamalkumardba
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 35
SELECT suser_sname( owner_sid ), * FROM sys.databases
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search