如何在SQL SERVER 2008中使用触发器 [英] how to use trigger in SQL SERVER 2008
问题描述
我在触发器中有一个查询plz尽快给我回复
以下是我的表格和插入代码
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,
thera是2张桌子
1件商品
2件商品
产品领域
-项目名称
-Size
-Purchase
-Available
-Balance
item字段
Item_Name
尺寸
库存
________________
一旦我们在产品领域输入记录,库存将自动在项目表中增加
例如
产品表项目TABLE
-Item名称包袋
-Size 3 3
-Purchase 10
-Available 10
-Balance 20库存20
一旦我们在包中插入第二条记录,产品表余额现在是20 + 10 = 30,那么30将会在现货的领带表中提升= 30
我的插入代码如下
-------------------------- -------------------------------------------------- --------------------------------
I have one query in trigger plz give me reply as soon as possible
below is my table and insert code
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
thera are 2 tables
1-product
2-item
product fields
-Item Name
-Size
-Purchase
-Available
-Balance
item Fields
Item_Name
Size
Stock
________________
As soon as we enter record in product fields stock will increase automatically in item table
For Example
Product Table Item TAble
-Item Name Bag Bag
-Size 3 3
-Purchase 10
-Available 10
-Balance 20 Stock 20
As soon as we insert second record in bag and product table balance is now 20+10=30 than that 30 will be upadted in tiem table in stock =30
my insert code is as below
------------------------------------------------------------------------------------------------------------
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\New_Project\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("insert into product values('" + TextBox1.Text + "','" + TextBox2.Text + "'," + TextBox3.Text + ",'" + TextBox4.Text + "','" + TextBox5.Text + "')", con);
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(Page.GetType(), "Submit", "<script language='javascript'>alert('Data is Saved.....!!!')</script>");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
con.Close();
GridView1.DataBind();
推荐答案
访问这里..
Triggers - Sql Server [ ^ ]
visit here..
Triggers -- Sql Server[^]
这篇关于如何在SQL SERVER 2008中使用触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!