have u heard of managed code?
your trigger can communicate with C# in managed code......
STEP 1)Write an assembly
using System.Data;
using System.Data.Sql;
using System.Data.SqlServer;
public class Test
{
public static void InsertTrigger()
{
SqlTriggerContext triggerContext = SqlContext.GetTriggerContext();
SqlPipe sqlPipe = SqlContext.GetPipe();
SqlCommand command = SqlContext.GetCommand();
if (triggerContext.TriggerAction == System.Data.Sql.TriggerAction.Insert)
{
try
{
//C# communication code here
}
catch (Exception e)
{
//EXCEPTION HANDLING CODE
}
}
}
}
STEP 2)Register the assembly in the database
CREATE ASSEMBLY Test FROM 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\Test\CLRProcedures\CS\Test.dll'
STEP 3)Create the trigger
CREATE TRIGGER InsertTrigger
ON Table FOR INSERT
AS
EXTERNAL NAME
[Name of the Assembly]:[Name of the Class]::[Name of the Method]
"//C# communication code here"
instead of this comment put code from here......
http://www.codeproject.com/cs/internet/smartmassemail.asp
No comments:
Post a Comment