SQL 서버 - DB 테이블의 데이터 변경에 대한 알림 처리
SQL Server Notification Services
; http://en.wikipedia.org/wiki/SQL_Server_Notification_Services
wmi Sql table notification
; http://www.ureader.com/msg/14861679.aspx
Sample: Using the WMI Event Provider with the .NET Framework
; http://msdn.microsoft.com/en-us/library/ms179315.aspx
using System;
using System.Management;
class SQLWEPExample
{
public static void Main(string[] args)
{
string query = @"SELECT * FROM DDL_EVENTS " ;
// Default namespace for default instance of SQL Server
string managementPath =
@"\\.\root\Microsoft\SqlServer\ServerEvents\MSSQLSERVER";
ManagementEventWatcher watcher =
new ManagementEventWatcher(new WqlEventQuery (query));
ManagementScope scope = new ManagementScope (managementPath);
scope.Connect();
watcher.Scope = scope;
Console.WriteLine("Watching...");
while (true)
{
ManagementBaseObject obj = watcher.WaitForNextEvent();
Console.WriteLine("Event!");
foreach (PropertyData data in obj.Properties)
{
Console.Write("{0}:", data.Name);
if (data.Value == null)
{
Console.WriteLine("<null>");
}
else
{
Console.WriteLine(data.Value.ToString());
}
}
Console.WriteLine("-----");
Console.WriteLine();
Console.WriteLine();
}
}
}