June 3, 2009 at 1:04 am
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!!!
---
June 3, 2009 at 1:15 am
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.
[font="Verdana"]Markus Bohse[/font]
June 3, 2009 at 1:22 am
Thanks you very much MarkusB for your quick info. 🙂
June 3, 2009 at 6:27 am
MarkusB,
Is it possible to achieve this through sql statement? Like sys.databases some thing like ....
---
June 3, 2009 at 6:32 am
sqluser (6/3/2009)
MarkusB,Is it possible to achieve this through sql statement? Like sys.databases some thing like ....
---
Is what possible?
[font="Verdana"]Markus Bohse[/font]
June 3, 2009 at 6:41 am
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.
---------------------------------------------------------------------
June 3, 2009 at 6:57 am
george sibbald (6/3/2009)
This gives the owner of the databaseselect 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...
---
December 27, 2013 at 1:27 am
SELECT suser_sname( owner_sid ), * FROM sys.databases
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply