Thursday, February 9, 2012

actual creator of a database

Does anyone know how to obain the actual creator of a database by using TSQL or SP? I need to know actual Login not DBO.

Thanks.

You can access the system table directly:

select suser_sname(sid)
from master..sysdatabases
where name = 'tempdb'

There maybe an inbuilt T-SQL function that would tell you this, which would be a preferable way of getting the info.


HTH!

|||

You cannot do this (exactly) that I know of. You can get the owner of the database using the code in the other post:

select suser_sname(sid)
from master..sysdatabases
where name = 'tempdb'

or

select name, suser_sname(owner_sid)

from sys.databases

The owner can be changed though using: sp_changedbowner, so you are actually getting the current owner. That may be good enough for your needs, but it is a caveat you should understand.

No comments:

Post a Comment