Greeting everyone!
In SqlDependency you can easy subscribe to data change using Query Notification mechanism. (or by setting odbc attributes)
SqlDependency dependency = new SqlDependency(
new SqlCommand("SELECT [ID], [Name] FROM [dbo].[tbl_Contact]", this.CurrentConnection)
);
dependency.OnChange += this.dependency_OnChange;
On the other hand, using native sql you can execute stored procedure on some DMV event. (like user logout)
create queue [myEventQueue] with activation (
status = on,
procedure_name = dbo.QueueProcessing,
max_queue_readers = 2,
execute as self
)
create service [myNotifications] on queue [myEventQueue]
([http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]);
CREATE EVENT NOTIFICATION [myEvent]
ON server
FOR AUDIT_LOGOUT
TO SERVICE 'myNotifications', 'current database'
My question is:
- Can we create and subcribe some event query to data change without SqlDependency (using native t-sql in Managment Studio)?
- Can we execute stored procedure when "some data modified"?
Thank you for any help!
P.S. Why i can't use triggers?
I have about 200 "events" wich are dependent on multiple tables with different predicates (filters). Unfortunately, users can change it.