Click here to Skip to main content
15,745,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Pls some one tell that how to insert values in 2 tables in single query, the table structure are:

Aircraft table

aid aname cruisingrange

and another table is


eid aid salary

these are the fields for both tables and i want to insert values in both tables in single query using primary and foreign key relationship using the trransaction

Pls some one tell......

1 solution

Essentially you can't update more than one table in a single query in sql2005

However, there are other ways to achieve the same effect - transactions, triggers, OUTPUT ...

Have a look at the responses to this link for some specific examples[^]
Share this answer
Maciej Los 23-Sep-13 15:36pm    
CHill60 23-Sep-13 15:42pm    
Thank you!
chander rani 28-Sep-13 8:28am    
I dont understand this, Pls help me with another example.
CHill60 29-Sep-13 15:35pm    
There were several different ways suggested on that link if I remember rightly. Basically, you cannot update two tables in a single query. My recommendation would be to create a Stored Procedure that contains two separate update statements. You can call the SP from (e.g.) C# as a single "call"

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