我有一個通用的clr觸發器,可以在插入,更新,刪除時將其附加到不同的表。 例如檢索在clr中觸發觸發器的sqlobject
[Microsoft.SqlServer.Server.SqlTrigger(Event = "FOR UPDATE, INSERT, DELETE")]
public static void TriggerHandle()
{
DataTable dataTable = new DataTable("Test");
SqlTriggerContext myContext = SqlContext.TriggerContext;
try
{
using (SqlConnection conn = new SqlConnection(CONNECTION_STRING))
{
conn.Open();
SqlCommand sqlComm = new SqlCommand();
sqlComm.Connection = conn;
switch (myContext.TriggerAction)
{
case TriggerAction.Insert:
sqlComm.CommandText = "Select *,'inserted' as operation from inserted";
break;
case TriggerAction.Update:
sqlComm.CommandText = "Select *,'updated' as operation from inserted";
break;
case TriggerAction.Delete:
sqlComm.CommandText = "Select *,'deleted' as operation from deleted";
break;
}
dataTable.Load(sqlComm.ExecuteReader(), LoadOption.Upsert);
SqlContext.Pipe.Send(String.Format("The datatable is populated with {0} rows ", dataTable.Rows.Count.ToString()));
}
}
...所以它不是特定的某個表。我怎麼才能找到,在clr觸發器,這是由觸發器更新的sql對象?