none
actual creator of a database

    Question

  • 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.

    Tuesday, September 11, 2007 3:26 PM

Answers

  • 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!

    Tuesday, September 11, 2007 3:54 PM
    Moderator
  • 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.

    Tuesday, September 11, 2007 4:00 PM
    Moderator

All replies

  • 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!

    Tuesday, September 11, 2007 3:54 PM
    Moderator
  • 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.

    Tuesday, September 11, 2007 4:00 PM
    Moderator