• Here is a Trigger that I created and currently use on SQL 2005 and 2008.

    It monitors when someone creates a new DB and emails me the information, including the create statement and the user.

    Note: it will not work on earlier versions of SQL.

    CREATE TRIGGER [DDL_CREATE_DATABASE_EVENT]

    ON ALL SERVER

    FOR CREATE_DATABASE

    AS

    DECLARE @bd varchar(max)

    Declare @tsql varchar(max)

    Set @tsql = EVENTDATA().value

    ('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]','varchar(max)')

    SET @bd = 'UserName: ' + UPPER(SUSER_NAME()) + '

    ServerName: ' + @@SERVERNAME + '

    Time: '+ CONVERT(varchar(25),Getdate()) + '

    HostName: ' + HOST_NAME() + '

    Database: ' + db_name() + '

    T-SQL: ' + @tsql

    BEGIN

    PRINT 'Make sure you have informed all DBAs before creating databases. This event has been logged'

    EXEC msdb.dbo.sp_send_dbmail @profile_name = 'SQL Database Mail',

    @recipients = 'myEmail@myDomain.com',

    @subject = 'A new database has been created!',

    @body_format = 'HTML',

    @importance = 'High',

    @body = @bd

    END

    GO

    ENABLE TRIGGER [DDL_CREATE_DATABASE_EVENT] ON ALL SERVER

    GO

    QUIGROUP- Need a Certified experienced DBA for a project or troubleshooting? Need help with programming, database recovery, performance tuning, ETL, SSRS or developing new databases? Contact us.. 1-786-273-9809