Jul 1, 2001 1 #1 levi71 Programmer Jul 1, 2001 5 US How do I automatically insert a value into multiple tables from a web based application using MS SQL 7 or MS SQL 2000.
How do I automatically insert a value into multiple tables from a web based application using MS SQL 7 or MS SQL 2000.
Jul 1, 2001 1 #2 tlbroadbent MIS Mar 16, 2001 9,982 US A couple of ways come to mind. You can send multiple insert statements in one SQL script or batch from your WEB APP. Insert table1 (col1, col2, col3, col4) Values (val1, val2, val3, val4) Insert table2 (col1, col2) Values (val1, val2) Insert table3 (col3, col4) Values (val3, val4) Or you can create a trigger on a table that would do the inserts in the other table(s) when a new record is inserted. Create Trigger trgInsert On Table1 For Insert As Set Nocount On Insert table2 Select col1, col2 From Inserted Insert table3 Select col3, col4 From Inserted Terry http://members.home.net/tlbroadbent/sqlarticles.htm "The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin Upvote 0 Downvote
A couple of ways come to mind. You can send multiple insert statements in one SQL script or batch from your WEB APP. Insert table1 (col1, col2, col3, col4) Values (val1, val2, val3, val4) Insert table2 (col1, col2) Values (val1, val2) Insert table3 (col3, col4) Values (val3, val4) Or you can create a trigger on a table that would do the inserts in the other table(s) when a new record is inserted. Create Trigger trgInsert On Table1 For Insert As Set Nocount On Insert table2 Select col1, col2 From Inserted Insert table3 Select col3, col4 From Inserted Terry http://members.home.net/tlbroadbent/sqlarticles.htm "The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin