Click here to Skip to main content
15,172,004 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have column named as 'SubmittedBySchool' in the table named 'SignOff'. The records under these columns have the date entered dynamically as and when the user clicks on the submit button in the web page. Now I want the data under this column to be copy to the column named 'DateTravelPlanSubmitted' in the table 'School' and also the data must be changed automatically in both the column each time the user clicks on the submit button. Can anyone help me to perform this task.
Updated 29-May-15 2:35am
F-ES Sitecore 28-May-15 9:43am
Use the INSERT INTO .. SELECT command. Google "t-sql insert into" if you don't know how to use it.
Advay Pandya 28-May-15 9:55am
I have a query on this. You want to copy data from one to another table. So the data will be inserted every time ? or the data will be inserted and updated both based on situation ?
user 3008 28-May-15 10:14am
update the data of the column DateTravelPlanSubmitted to the table Schools each time it changes in the SignOff table. This update must be automatically
ZurdoDev 28-May-15 13:18pm
1. Reply to the comment so that the user is notified.
2. Use triggers. Google for examples.
Nelson Belmont 28-May-15 10:41am
Have you tried using triggers?


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

   ON  SignOff

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


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

Advay Pandya
user 3008 29-May-15 7:33am
Sorry about that. I want the this updating to be done using ASP.NET code, so that this will data will be copied to the table Schools each time it is been changed in the website.
Advay Pandya 1-Jun-15 1:53am
Hi, yes.. If you set trigger then no matter from where are you updating the table it will be reflected. Whenever your table is updated the trigger will fire and it will update another table accordingly. If you are updating the table using ASP.Net still the trigger will update another table automatically. Please let me know if you need more info on this.
user 3008 2-Jun-15 12:13pm
Thank you so much for the solution. It is now working perfectly. :-) :-)
Advay Pandya 3-Jun-15 2:04am
Always Welcome :)
Create a trigger for INSERT, Update and Delete on table 'School' and write below query

Insert Into School(
SignOff SO

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900