July 26, 2011 at 1:09 pm
Is there a sql alert that tells a new db is created?
or is there a simple way to setup to notify dba about a new db is created?
Thanks
July 26, 2011 at 1:10 pm
I'd check the default trace, I'm sure it's a logged event.
From there on out it's a matter of checking regularly...
Having issues with users creating dbs without your knowledge?
July 26, 2011 at 1:15 pm
also, you can use a server wide DDL trigger for CREATE_DATABASE, but if the database is created new from a restore, it's not detected, for whatever reason that;s not a CREATE_DATABASE event but a RESOTRE event instead(and that doesn't count as a DDL event)
....you'd have to use an event notification to track that.
Lowell
July 26, 2011 at 1:18 pm
i was playing witht eh event notifications for that for a while; on a certians erver, i was trying to create a suite of roles in any database that was created or restored; i figured if i could create a role based on the RESTORE_DATABASE or CREATE_DATABASE events, i could do all sorts of things...need to pull that back out and play with it.
Lowell
July 26, 2011 at 2:19 pm
July 26, 2011 at 2:27 pm
Can you explain a little in detail how I can be alerted by using default trace or using policy management when there is a new database created?
Thanks
July 26, 2011 at 2:29 pm
July 26, 2011 at 2:32 pm
SQL server 2008 standard
July 26, 2011 at 3:45 pm
you can do this multiple ways
1. Trigger
CREATE trigger [ddl_CreateDatabase]
on ALL Server
for Create_database
As
If context_info() 0x4C6F6C20596F752064696420646F206974203A44 — backdoor
begin
RAISERROR (‘Creating databases has been disalowed’,10, 1)
Rollback;
end
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER [ddl_CreateDatabase] ON ALL SERVER
3. Some other Notification Method
--Create a queue to receive messages.
CREATE QUEUE NotifyQueue ;
GO
--Create a service on the queue that references
--the event notifications contract.
CREATE SERVICE NotifyService
ON QUEUE NotifyQueue
([http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]);
GO
--Create a route on the service to define the address
--to which Service Broker sends messages for the service.
CREATE ROUTE NotifyRoute
WITH SERVICE_NAME = 'NotifyService',
ADDRESS = 'LOCAL';
GO
--Create the event notification.
CREATE EVENT NOTIFICATION log_ddl1
ON SERVER
FOR Object_Created
TO SERVICE 'NotifyService',
'8140a771-3c4b-4479-8ac0-81008ab17984' ;
July 27, 2011 at 12:41 am
Using default trace can give you answers but if your server has some heavy activity going, the default traces will be wiped out soon. Also, I am not sure but you cannot read from a system trace file if it is currently used. I had tried that but failed so had to copy that file to some other location and then read from it.
I will prefer using triggers or some other notification methods as described above.
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply