标签:blog io ar os for sp on 2014 art
using System; using System.Data; using System.Data.SqlClient; using Microsoft.SqlServer.Server; public partial class Triggers { // 为目标输入现有表或视图并取消对属性行的注释 [Microsoft.SqlServer.Server.SqlTrigger (Name="Trigger1", Target="Unit_E", Event="FOR INSERT")] public static void Trigger1() { SqlPipe sp = SqlContext.Pipe; string sql = "insert into Unit_E1 select * from inserted"; using (SqlConnection conn = new SqlConnection("context connection=true")) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.CommandText = sql; SqlDataReader rdr = cmd.ExecuteReader(); sp.Send(rdr); conn.Close(); } //SqlContext.Pipe.Send("Trigger FIRED"); } }
标签:blog io ar os for sp on 2014 art
原文地址:http://blog.csdn.net/lucky51222/article/details/40737431