Triggers can now also be implemented through .NET code. Triggers are similar to stored procedures but they can only have a return type of void. A new object, SqlTriggerContext, provides access to the INSERTED and DELETED tables that you might have used in the past with a T-SQL trigger. Unlike Triggers in SQL Server 2000, triggers (both T-SQL and CLR) can be tied to statements over than INSERT, UPDATE, and DELETE. For example, you can create a trigger that is executed every time a new table is created, etc.
Here is an example, create a new class and then create a new public static method.
public static void TableCreated()
{
// this gets you access to the trigger
SqlTriggerContext triggerContext = SqlContext.GetTriggerContext();
// determine what kind of action just occurred
if (trigger.TriggerAction == TriggerAction.CreateTable)
{
// do something (i.e.: send e-mail, insert a record somewhere, etc.)
}
}
Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=179