August 10, 2015 at 8:23 am
I would like to register my C# module for SQL server event notifications. These events are just DB creation and DB deletion.
Is there any way wherein we can pass the callback function to SQL SMO , so that it will notify us back on db creation and deletion events..
Many Thanks in advance...
August 12, 2015 at 11:42 pm
Not sure about how you might do this using SMO as you described but creating a server event notification requires a Service Broker queue to be setup first and is a small series of T-SQL statements. From there your C# app would need to be coded up to look for and process messages in the SB queue.
See Example A here CREATE EVENT NOTIFICATION (Transact-SQL) and change the event to CREATE_DATABASE or DROP_DATABASE to try it out.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
August 13, 2015 at 12:32 am
Thanks a lot for your response.
I am OK by achieving the notification env setting up using T-SQL statements.
please share any link for calling C# modules from the Service Broker if you have any..
~Regards
Ashish
August 13, 2015 at 5:53 am
Service Broker is a queuing system so won't be calling out as you might be thinking of it. You can attach to the queue an "activation stored procedure" that the system can invoke for you but that procedure is obviously running on the database server.
At the end of the day if you want a C# app outside the database to run when something is added to the queue you C poll the queue yourself looking for messages or you can do an internet search for"service broker external activation" which tried to handle the polling piece for you.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply