Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 inserts into base table and relational table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-26 : 11:05:21
senthil writes "There are 2 base tables with many:many relation.

Table A with col1, col2 and more columns.
col1 is an identity column and PK.
col2 is varchar and other columns are of different datatypes.

Table B has col1 and col2.
col1 is identity column and PK.
col2 is varchar.
The rows in table B are already available.

Table AB is a relational table which has col1 and col2.
col1 is FK from A.col1
col2 is FK from B.col1

I insert a new row in table A which gives a new auto generated number for col1.

Now I have to insert multiple rows in table AB with this newly generated number from A and other rows of col1 from B.

This has to happen in a single transaction with the minimum number of queries.

How can i do it?"
   

- Advertisement -