插入一个值后的“触发事件"应为“更新" [英] Trigger Event after insert one value should be Update

查看:62
本文介绍了插入一个值后的“触发事件"应为“更新"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

create table Test1
(
  WRO varchar(10),
  Test_No varchar(10),
  TestDate datetime
);

insert into Test1(WRO,TestDate) values('T0001',now());
create table Test2
(
  WRO varchar(10),
  Test_No varchar(10),
  Test2Date datetime,
  TestAmount varchar(10)
);


在Test2表Test_No上插入后,我必须在Test1 Test_No上进行更新
公共领域WRO

请帮助我


在此先感谢...


i have to update on Test1 Test_No after insert on Test2 table Test_No both have
common field WRO

please help me


Thanks in Advance...

推荐答案

哈里斯,
我可以向您展示另一种简单的方法,U可以使用scope_identity()来为您提供最后插入的值.声明一个变量并维护scopeidentity,您可以在insert语句下面的update语句中使用它.

SELECT SCOPE_IDENTITY()AS [SCOPE_IDENTITY]
谢谢
Hi haresh,
I can show you an another easy way, U can use scope_identity() which will give you the last inserted value. Declare a variable and maintain the scopeidentity, which you can use in the update statement below of your insert statement.

SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY]
ThankYou


我解决了我的自我...

谢谢
i solved my self...

thank you


这篇关于插入一个值后的“触发事件"应为“更新"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆