How find who created database and from which system it was created?

Sai 126 Reputation points
2021-10-21T10:45:48.19+00:00

I have seen new database in my server. that was created nearly 45 days back. I have tried to check using standard report but no luck.

SQL version: SQL server 2017 enterprise.

Is it possible to find who created database and from which system it was created?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,642 questions
{count} votes

Accepted answer
  1. Ronen Ariely 15,096 Reputation points
    2021-10-22T03:32:08.84+00:00

    Good day Sai :-)

    from which system it was created?

    For this we will need to use the first step and cross information with the operating system information and the active domain and so on. Fot he scope of this trhead I will present the full answer for the first part of the question which is related to the work of the (very advanced) DBA.

    How find who created database?

    (1) It is very simple to get the owner of the DATABASE, which in many cases (especially in small companies) will probably be the same as the LOGIN who created the DATABASE, but the owner of the DATABASE is not necessarily the LOGIN who created the database since someone might have ALTER AUTHORIZATION for databases and change the LOGIN to another LOGIN.

    Unfortunately, the information about the LOGIN who execute the creation of the database, is not stored in the database.

    but no worry, this is why we are here :-)

    SQL Server stores the information about DDL actions like CREATE DATABASE, simply not in the database. Pulling the information is a bit more complex and requires a bit of internals knowledge and parsing of data and using an undocumented tool. It is not that complicated actually.

    So... where SQL Server store information about DDL actions?

    Answer: In the transaction log obviously :-)

    And this is where we can get the information about the real LOGIN which created the database, assuming you have all the backups of the transaction log.

    Here is a nice post I wrote several years ago to find who deleted a row from the table. The solution is exactly the same except that instead of searching for the action LOP_DELETE_ROWS we need to search for the action ``

    https://ariely.info/Blog/tabid/83/EntryId/154/SQL-Server-Who-deleted-my-record-last-time.aspx

    I will write a fast blog step by step with full demo in a few XX (I have no idea how long it will take :-) But you have all the information and I just want to present full demo)

    UPDATE: Step-By-Step full demo!

    I published a full demo from the CREATE DATABASE to finding who created the database

    https://ariely.info/Blog/tabid/83/EntryId/303/SQL-Server-Who-created-the-database.aspx

    I hope this is useful :-)


3 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 100.8K Reputation points MVP
    2021-10-21T21:59:37.75+00:00

    If you had no suitable auditing set up, the answer is no, you can't.

    0 comments No comments

  2. Seeya Xi-MSFT 16,436 Reputation points
    2021-10-22T02:21:03.457+00:00

    Hi Sai-0641,

    You can use the following script to find who created database.

    SELECT suser_sname( owner_sid ) AS 'Creator', * FROM sys.databases  
    

    But could you describe in detail what you mean about "which system" ?

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Ron Klimaszewski 1 Reputation point
    2021-10-22T13:45:11.687+00:00

    This information is in the default trace (or one of the rollover files). Search for [EventClass]=46, [EventSubclass]=0, [DatabaseName]='whoCreatedMe'. If recent enough, you could use the built-in Schema Changes report.