Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Any one can help me that how to write querry to insert values to two different tables in single transaction..


Thanks in Advance

Seshu
Posted

1 solution

This is easy.
Just execute both queries within the same transaction.
BEGIN TRANSACTION

INSERT INTO Table1(Column1....) VALUES (Value1...)
INSERT INTO Table2(Column1....) VALUES (Value1...)

COMMIT TRANSACTION
 
Share this answer
 
Comments
Kim Togo 31-May-11 7:56am    
Simple - My 5.
Abhinav S 31-May-11 7:58am    
Thanks Kim.

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