I use below trigger to email me when a database is created or dropped.
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 'Database has been created'
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Default',
@recipients = 'abc@xyz',
@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
is there a way we can get notification when a table is created or altered or dropped ?
Please share if you have script
Thanks