且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

想要将一列的记录从表复制到同一数据库中的另一个表

更新时间:2022-12-12 11:16:51





根据我的理解你想要的每当SignOff表的数据更新时,更新表Schools的DateTravelPlanSubmitted列。



如果这是正确的,那么你可以在更新时创建一个触发器



Hi,

As per my understanding you want to update column "DateTravelPlanSubmitted" of the table "Schools" whenever data of "SignOff" table is updated.

If this is correct then you can create a trigger on update

CREATE TRIGGER Trigger1
   ON  SignOff
   AFTER UPDATE
AS
BEGIN

    Update Schools  SET DateTravelPlanSubmitted = [Your Value]
         from inserted
    WHERE Schools.PremaryKey = inserted.Primarykey

END







请告诉我你有不同的要求然后我理解或者你想了解更多信息。



谢谢

Advay Pandya




Please let me know of you have different requirement then I understood or you want more information.

Thanks
Advay Pandya


为INSERT创建一个触发器,更新和删除表'学校'并写下面的查询





插入学校(

[ DateTravelPlanSubmitted]



选择

SO。[SubmittedBySchool]

来自

SignOff SO
Create a trigger for INSERT, Update and Delete on table 'School' and write below query


Insert Into School(
[DateTravelPlanSubmitted]
)
Select
SO.[SubmittedBySchool]
From
SignOff SO